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 two subdomains on my VPS, i have registered the two subdomains in my DNS pointing to the same IP address.

the version installed is Server version: Apache/2.4.7 for Ubuntu 12.04.

I've enabled the sites with the a2ensite command and i have enable the module vhost_alias. restart and reloaded many times

stable.mydomain.com

<VirtualHost *:80>        
    ServerName stable.mydomain.com

    DocumentRoot /var/www/stable/web

    <Directory /var/www/stable/web>
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

beta.mydomain.com

<VirtualHost *:80>

    ServerName beta.mydomain.com

    DocumentRoot /var/www/beta/web

    <Directory /var/www/beta/web>
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            order allow,deny
            Allow from all
    </Directory>
</VirtualHost>

my trouble is pointing my browser to any url always i get the same content and to add more confusion when i execute service apache2 reload in the two subdomains i get the content from beta.mydomain.com and when execute service apache2 restart in the two subdomains i get the content of stable.mydomain.com.

I have spent about 5 hours trying to fix this

update

event i try with the VirtualDocumentRoot

<Virtualhost *:80>
    VirtualDocumentRoot "/var/www/%1/web"
    ServerName stable.mydomain.com
    ServerAlias *.mydomain.com
    UseCanonicalName Off
    <Directory "/var/www/*">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</Virtualhost>

with the same behavior explained before this update

update 2

I dont have virtualhost overlap, every vhost has unique name and unique DocumentoRoot, even i have the <VirtualHost _defaut_:80> defined.

i check with apachectl -S:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server XXX.XXX.XXX.XXX (/etc/apache2/apache2.conf:220)
         port 80 namevhost XXX.XXX.XXX.XXX (/etc/apache2/apache2.conf:220)
         port 80 namevhost beta.mydomain.com (/etc/apache2/sites-enabled/beta.conf:1)
         port 80 namevhost stable.mydomain.com (/etc/apache2/sites-enabled/stable.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
share|improve this question
    
maybe you have virtualhost overlap, and think you missing the directive NameVirtualHost *:80 read this wiki.apache.org/httpd/TroubleshootingVhosts and you are missing the default virtual host httpd.apache.org/docs/2.2/vhosts/examples.html –  c4f4t0r Mar 1 at 11:54
    
the directorive NameVirtualHost is deprecated AH00548: NameVirtualHost has no effect and will be removed in the next release –  rkmax Mar 1 at 13:40
    
Did you try removing the default server configuration in httpd.conf? –  edvinas.me Mar 1 at 14:37
    
@edvinas.me yes i removed it –  rkmax Mar 1 at 15:18
    
can you post apache2.conf as the problem is due to something in that config file. –  edvinas.me Mar 3 at 18:06

1 Answer 1

Update

This is likely caused by apache2.conf

default server XXX.XXX.XXX.XXX (/etc/apache2/apache2.conf:220)

You should post your apache2.conf

httpd.conf (or apache.conf or apache2.conf depending on distribution)

Make sure you have these:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

NameVirtualHost *:80

Make sure there is no other NameVirtualHost directive in main config.

httpd-vhosts.conf

<VirtualHost *:80>        
    ServerName stable.mydomain.com
    DocumentRoot /var/www/stable/web
    UseCanonicalName on
    <Directory /var/www/stable/web>
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>

    ServerName beta.mydomain.com

    DocumentRoot /var/www/beta/web
    UseCanonicalName on
    <Directory /var/www/beta/web>
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Also make sure that you default httpd.conf configuration does not include any defined servers, as vhosts might be overlapping with that.

share|improve this answer
    
i append the UseCaninicalName on without success –  rkmax Mar 1 at 15:21
    
I am afraid appending will not fix this as it is clear the problem is caused by some other part of your config. I would guess it is port 80 namevhost XXX.XXX.XXX.XXX (/etc/apache2/apache2.conf:220) So please use default apache2.conf with only php setup and my vhost configs. –  edvinas.me Mar 3 at 18:05

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.