Solved

Help Configurng Vhost.conf file on EC2 Instance

Posted on 2014-04-29
6
673 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
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:small_student
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

777 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