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 ubuntu server with apache setup, the main domain on the server is a subdomain app.example.com, which is working fine.

Now if I setup john.app.example.com, then that also is displaying the web page of app.example.com, the DocumentRoot for john.app.example.com is different, still it shows the web page of app.example.com. how can I resolve this, so john.app.example.com displays the pages that are there in its DocumentRoot.

share|improve this question
    
Can we get the httpd.conf posted in please so we can see the Vhosts –  Jacob Jan 31 '11 at 4:37

1 Answer 1

1 Check active NameVirtualHost. Open /etc/apache2/ports.conf file:

NameVirtualHost *:80

2 Check DNS

# ping app.local
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.

# ping john.app.local
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.

3 Check Apache config(/etc/apache2/sites-enabled/000-default):

<VirtualHost *:80>
        ServerName app.local
        DocumentRoot /var/www
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName john.app.local
        DocumentRoot /var/www/john
</VirtualHost>

$ sudo apache2ctl configtest
Syntax OK

$ sudo  apache2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server app.local (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost app.local (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost john.app.local (/etc/apache2/sites-enabled/000-default:12)

4 Test Apache:

$ curl http://john.app.local
john
$ curl http://app.local
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
share|improve this answer

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.