Solved

Help Configurng Vhost.conf file on EC2 Instance

Posted on 2014-04-29
6
672 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now