Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two virtual hosts, but apache seems to be defaulting to one of them.

Here is host #1:

<VirtualHost *>

        ServerName goiclub.com
        ServerAlias www.goiclub.com *.goiclub.com
        ServerAdmin webmaster@localhost

        DocumentRoot /home/casey/public_html/goiclub/public

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/casey/public_html/goiclub/public>
                DirectoryIndex index.php index.htm index.html
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>



        ErrorLog /home/casey/public_html/goiclub/log/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel debug

        CustomLog /home/casey/public_html/goiclub/log/access.log combined
        ServerSignature On

        Alias /doc/ /usr/share/doc/
        <Directory "/usr/share/doc/">
                Options Indexes MultiViews FollowSymLinks
                AllowOverride None
                Order deny,allow
                Deny from all
                Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>

</VirtualHost>

And this is the other vhost:

<VirtualHost *>
ServerAdmin webmaster@geticlub.com
ServerName geticlub.com
ServerAlias www.geticlub.com *.geticlub.com

DirectoryIndex index.php
DocumentRoot /home/casey/public_html/geticlub/public

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/casey/public_html/geticlub/public>
                DirectoryIndex index.php index.htm index.html
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

LogLevel debug
ErrorLog /home/casey/public_html/geticlub/log/error.log
CustomLog /home/casey/public_html/geticlub/log/access.log combined
</VirtualHost>

whether I type in goiclub.com or geticlub.com it returns 'geticlub.com' vhost. Does anyone know why?

Also this might be helpful:

sudo apache2ctl -t -D DUMP_VHOSTS
apache2: Could not reliably determine the server's fully qualified domain name, using 50.56.118.158 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:*                    geticlub.com (/etc/apache2/sites-enabled/geticlub.com:1)
*:*                    goiclub.com (/etc/apache2/sites-enabled/goiclub.com:1)
share|improve this question
    
are these domains present in your /etc/hosts? –  freethinker May 22 '11 at 5:26

1 Answer 1

up vote 3 down vote accepted

You need NameVirtualHost set up.

Open ports.conf and add: (You can also put it above the first <virtualHost>

NameVirtualHost *:80
Listen 80

You can also use the ip address instead of the wildcard.

Your vhost has to be formatted exactly the same as the NameVirtualHost format.

If it's formatted like this:

NameVirtualHost 1.2.3.4:8080

then vhost should be:

<VirtualHost 1.2.3.4:8080>

share|improve this answer
    
Thanks @Chris_O, that's exactly what I was missing. –  Casey Flynn May 22 '11 at 18:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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