Solved

Help Configurng Vhost.conf file on EC2 Instance

Posted on 2014-04-29
6
679 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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