Solved

Help Configurng Vhost.conf file on EC2 Instance

Posted on 2014-04-29
6
670 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
Comment Utility
Yuu should enable the sites with the following command

sudo a2ensite abc.com
0
 

Author Comment

by:sharingsunshine
Comment Utility
I am getting

sudo: a2ensite: command not found
0
 
LVL 32

Accepted Solution

by:
shalomc earned 500 total points
Comment Utility
> 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:sharingsunshine
Comment Utility
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 32

Expert Comment

by:shalomc
Comment Utility
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
Comment Utility
Thanks for your help.  You have answered my question.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 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

9 Experts available now in Live!

Get 1:1 Help Now