virtual hosts problem on ubuntu 12.4

July 30, 2014 1.5k views

Hi,

I am fairly new to this, so I probably missed something obvious.

I have a ubuntu 12.4 apache2 setup. I have two sites running, they are working fine. But when I try to set up a third one, the second site gets redirected to the third. If I set up a fourth it gets redirected to the last. My vhost config are all like:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/generationalbator/public_html
ServerName www.generationalbator.be
Serveralias generationalbator.be
Serveralias www.generationalbator.be

ErrorLog /var/www/generationalbator/logs/error.log
Loglevel warn
CustomLog /var/www/generationalbator/logs/access.log combined

<Directory /var/www/generationalbator/public_html>
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

</VirtualHost>

Any ideas?

3 Answers

Hi,

are the virtual hosts stored in separate files in the sites-available directory? Have you run a2ensite on all configs?

Are you able to post all three virtual host files?

  • I have three virtual host files. Is it better to have only one?

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/vendiscapital/public_html
    ServerName www.vendiscapital.com
    Serveralias vendiscapital.com
    Serveralias www.vendiscapital.com
    ErrorLog /var/www/vendiscapital/logs/error.log
    Loglevel warn
    CustomLog /var/www/vendiscapital/logs/access.log combined
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/skyo/publichtml
    ServerName www.skyo.be
    Serveralias sky.be
    Serveralias www.skyo.be
    ErrorLog /var/www/skyo/logs/error.log
    Loglevel warn
    CustomLog /var/www/skyo/logs/access.log combined
    <Directory /var/www/skyo/publichtml>
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>
    
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    
    DocumentRoot /var/www/generationalbator/public_html
    ServerName www.generationalbator.be
    Serveralias generationalbator.be
    Serveralias www.generationalbator.be
    
    ErrorLog /var/www/generationalbator/logs/error.log
    Loglevel warn
    CustomLog /var/www/generationalbator/logs/access.log combined
    
    <Directory /var/www/generationalbator/public_html>
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>
    
    </VirtualHost>
    

    thanks!

solved. I put them in one file, ran a2ensite and it functions!

Glad it's solved! Having separate files is not an issue, that's how I do it, I'm thinking maybe one of the configs wasn't enabled? Never mind though!

Have another answer? Share your knowledge.