Solved

Help Configurng Vhost.conf file on EC2 Instance

Posted on 2014-04-29
6
677 Views
Last Modified: 2014-04-30
I have configured a vhost.conf file and it appears to be not set up correctly.  Here is a copy of the file

NameVirtualHost *:80

<VirtualHost x.x.x.x:80>
ServerName abc.com
DocumentRoot /var/www/html/abc.com
</VirtualHost>

<VirtualHost *:80>
ServerName def.com
DocumentRoot /var/www/html/def.com
</VirtualHost>

<VirtualHost *:80>
ServerName ghi.com
DocumentRoot /var/www/html/ghi.com
</VirtualHost>

When I try to access http://public_dns/phpinfo.php
I get this error
[Tue Apr 29 16:52:35 2014] [client 1.1.1.1]script '/var/www/html/def.com/phpinfo.php' not found or unable to stat

To solve this I put phpinfo.php in /var/www/html/def.com

My question is why is it defaulting to def.com and do I have the vhost.conf file set up correctly?
0
Comment
Question by:sharingsunshine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:Monis Monther
ID: 40030774
Yuu should enable the sites with the following command

sudo a2ensite abc.com
0
 

Author Comment

by:sharingsunshine
ID: 40031038
I am getting

sudo: a2ensite: command not found
0
 
LVL 33

Accepted Solution

by:
shalomc earned 500 total points
ID: 40031420
> http://public_dns/phpinfo.php 

The first generic vhost defined by <VirtualHost *:80>  is the default server in your case def.com.

You can use <VirtualHost *:80> for all of the hosts. Specify an IP address only when you have a scenario that requires it.

If you want to access abc.com, you have to either point an A record of abc.com to the IP address, or point a CNAME to the public name provided by EC2.
Only then you can access http://abc.com/phpinfo.php 

to verify the abc configuration immediately, try to use curl in a creative way:
curl -H "Host: abs.com" http://public_dns/phpinfo.php
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sharingsunshine
ID: 40032822
Thanks for explaining the default.  Now if I were to assign an elastic ip address to each domain, how would I access them before the dns was actually propogated?
0
 
LVL 33

Expert Comment

by:shalomc
ID: 40033058
Afaik, you can only have 1 EIP per server. You need to run in VPC to have multiple EIP.
But the good news is that you usually don't need multiple IP addresses, the setup you do lets you run multiple domains with only 1 single IP.  
Even for SSL which requires a static IP you can have a SAN cert with multiple domains and a single IP.

To access them before the DNS is propagated, use the curl command I posted with the spoofed host header. It is there for this reason :)
0
 

Author Comment

by:sharingsunshine
ID: 40033112
Thanks for your help.  You have answered my question.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question