I am trying to host 2 website xxx.com and yyy.com on a single amazon ec2 instance.
So far this is what I have done.
Created ec2 instance with Ubuntu and set up apache, mysql & Php
On Ec2 I have added 2 elastic IP address and associate them with my primary private IP address and secondary private IP address.
Using amazon route53 I have added “A” records for each domain to point to its Elastic IP address.
And lastly created virtual host conf file in apache and activate those site. The conf file looks like below:
ServerName xxx.com
ServerAlias www.xxx.com
ServerAdmin my email address
DocumentRoot /var/www/xxx.com/public_html
ErrorLog /var/www/xxx.com/logs/error.log
CustomLog /var/www/xxx.com/logs/access.log combined
After all this it’s still not working.
For first website it says “Google Chrome could not load the web page because www.xxx.com took too long to respond. The website may be down or you may be experiencing issues with your Internet connection.
For second website it’s still going to its domain name registrar’s home page (even after setting NS records)
Any help is much appreciated
Best Answer
Assuming you're running Apache 2, your
/etc/apache2/
directory should have asites-available
directory inside of it. This is where you want to configure your sites. You'll create a file for each of your sites that looks something like this:Then, in
/etc/apache2/ports.conf
, you'll configure Apache to accept virtual hosts for requests coming in on port 80:(
Listen 80
should already be inports.conf
; I included it to show where in the file to put theNameVirtualHost
, although the position doesn't actually matter)Lastly, run
a2ensite
on each of your virtual hosts to enable them.a2ensite
takes as its argument the name of the site configuration file. So, for example, if you had/etc/apache2/sites-available/xxx.com
and/etc/apache2/sites-available/yyy.com
, you'd doa2ensite xxx.com
anda2ensite yyy.com
.Then all you need to do is reload the Apache configuration with
service apache2 reload
, and you should be ready to go.