Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm learning to configure name-based virtual host for apache 2.

Right now, my domain http://mydomain.com points to /var/www/index.html. I want it to point to my newly created /srv/www/mydomain.com/public_html/index.html.

I currently have two files:

  • /etc/apache2/sites-available/default
  • /etc/apache2/sites-available/mydomain.com

This is what they look like:

/etc/apache2/sites-available/default

NameVirtualHost myipaddr:80

<VirtualHost myipaddr:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
## other default directives
</VirtualHost>

/etc/apache2/sites-available/mydomain.com

<VirtualHost *:80>
     ServerAdmin mydomain@mydomain.com
     ServerName mydomain.com
     ServerAlias www.mydomain.com
     DocumentRoot /srv/www/mydomain.com/public_html/
     ErrorLog /srv/www/mydomain.com/logs/error.log
     CustomLog /srv/www/mydomain.com/logs/access.log combined
</VirtualHost>

I executed a a2ensite mydomain.com and restarted apache, but http://mydomain.com still points to the default /var/www/ directory. I guess apache is not registering my /etc/apache2/sites-available/mydomain.com file?

Did I miss a step in my configuration and installation?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

I am not sure that it is the problem, but the first thing that sticks out is that your are using an IP in your NameVirtualHost setting, and a wildcard in the for the mydomain.com. You probably should use a wildcard for the NameVirtualHost and the default virtual host.

share|improve this answer
    
hey, that worked! Thank you! –  John Oct 12 '09 at 16:47
add comment
  • you should set a different name for "default"

ServerName notwww.mydomain.com

  • also you can set all NameVirtualHost and VirtualHost to *:80 just for uniformity of the config
share|improve this answer
add comment

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.