0

I have an AWS virtual server, with ubuntu 14.04 and apache 2.4.7. I have two domain names (let's say name1.com and name2.com), and I wanted both them to point to the IP of the server, and that apache redirected automatically to the folders (lets say /var/www/html/name1 and /var/www/html/name2 ).

Both sites are avalaible under http://ip-server/name1 and http://ip-server/name2.

I follow the usual instructions: In /etc/apache2/sites-available/ I copy 000-default.conf to 001-name1.conf. This is the content of the file:

<VirtualHost *:80>
    ServerName name1.com
    ServerAlias www.name1.com
    DocumentRoot /var/www/html/name1
    LogLevel error
    ErrorLog ${APACHE_LOG_DIR}/name1.error.log
    CustomLog ${APACHE_LOG_DIR}/name1.access.log combined
</VirtualHost>

Then I activate it with sudo a2ensite 001-name1.conf, and restart apache with sudo service apache2 restart.

But when I try http://name1.com (in a new private-mode brownser to avoid cache), it still redirects me to the defect index.html of apache.

When I run apache2ctl -S I get:

VirtualHost configuration:
   *:80                   is a NameVirtualHost
     default server ip-x-x-x-x.eu-west-1.compute.internal (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost ip--x-x-x-x.eu-west-1.compute.internal (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost name1.com (/etc/apache2/sites-enabled/001-name1.conf:1)
             alias www.name1.com

The logs are empty, so I don't know what else to do. Any ideas?

0

Start by disabling the default site (sudo a2dissite 000-default.conf). If you're not serving content there, then remove it.

The order in which sites are loaded matters (that's why default is prefixed with 000). The default site will be the first .conf loaded (based on alphabetical ordering). If you have ServerName set in your default.conf, then it will respond regardless of the vHosts that come after it.

Once you disable the default site, bounce apache, and comment below if it doesn't work. we'll try something else.

2
  • OK, so I disabled de default site and added 002-name2.conf with the parameters of the 2nd site. The problems now are: 1) The Wordpress site under name1 has lost the style. Probably related with the Mysql db, that keeps pointing to the ip-server. 2) Pointing to http://site2.com shows nothing. 3) Other content that was available under 'ip-server/anotherfolder', now is not avalaible. I had tried moving 000-default.confto 003-default.conf, but no change. – elrezad Jul 23 '14 at 15:59
  • The content of apache2ctl is <br/> VirtualHost configuration: *:80 is a NameVirtualHost default server name1.com (/etc/apache2/sites-enabled/001-name1.conf:1) port 80 namevhost name1.com (/etc/apache2/sites-enabled/001-nam1.conf:1) alias www.name1.com port 80 namevhost name2.eu (/etc/apache2/sites-enabled/002-name2.conf:1) alias www.name2.eu port 80 namevhost ip-server (/etc/apache2/sites-enabled/003-default.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www" – elrezad Jul 23 '14 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.