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 have a domain domain.com and a subdomain sub.domain.com .

In apache2/sites-available I have 2 vhosts files: domain and sub.

When I do a2ensite sub the subdomain overwrites the domain, so when I go to see the main domain I see the content for the subdomain. WHen the subdomain is added both the domain and the subdomain point to the subdomain.

What am I doing wrong?

Here are the vhosts

DOMAIN

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.domain.com

    DocumentRoot /var/www/domain/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/domain/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            # This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#            RedirectMatch ^/$ /apache2-default/
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

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

    CustomLog /var/log/apache2/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>

SUBDOMAIN

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName sub.domain.com

    DocumentRoot /var/www/sub/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/sub/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            # This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#            RedirectMatch ^/$ /apache2-default/
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

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

    CustomLog /var/log/apache2/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>
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

I have not read the configuration files yet. But I would like you to definitely go and check /etc/apache2/sites-enabled

Is sub-domain linked with a number before the domain.com?

example 010-sub links to /etc/apache2/subdomain.conf

and 020-sub links to /etc/apache2/domain.conf

so that Apache will parse first subdomain.conf given a request.

share|improve this answer
    
no they are not. can I add manually the priority number? –  Elzo Valugi Oct 21 '10 at 8:48
    
renaming them in sites-available and reloading them worked for the moment. another resource on the issue here. serverfault.com/questions/132770/… –  Elzo Valugi Oct 21 '10 at 8:55
    
So I assume your issue is solved, what you can do is rm a file and ln -s ... it again –  user36845 Oct 21 '10 at 17:08
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.