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 been trying to set up a subdomain on my local development environment, dev.localhost. I'm using Ubuntu 11.10 and Apache2. So far, I've edited my host file to include the line 127.0.0.1 dev.localhost. I've created a file called axis in /etc/apache2/sites-available which looks like this:

<VirtualHost *:80>
    DocumentRoot /var/www/Axis/trunk
    ServerName dev.localhost
    ServerAlias *.localhost

    <Directory /var/www/Axis/trunk/>
            Options Indexes FollowSymLinks MultiViews +Includes
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

I then enabled the site with sudo a2ensite axis. I encountered a no host named error and added the line ServerName localhost to my default file in sites-available. I also encountered an error that had something to do with NameVirtualHost, which I solved by adding NameVirtualHost *:80 to httpd.conf and also commenting it out in ports.conf.

Now, when I navigate to dev.localhost I get the SAME webpage as I would if I navigated to localhost. In other words, both localhost and dev.localhost point to /var/www but I want dev.localhost to point to /var/www/Axis/trunk.

Any idea where I'm going wrong? Thanks

EDIT: output from apache2ctl -S

ulimit: 88: error setting limit (Operation not permitted)
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
     default server localhost (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost dev.localhost (/etc/apache2/sites-enabled/axis:1)
Syntax OK
share|improve this question
    
What was the error? Can you edit your question to include the output from apache2ctl -S? –  Shane Madden Mar 12 '12 at 17:02
    
There is no error, it just doesn't route to the expected folder. I posted the results of apache2ctl -S –  Obi-wan Jacobi Mar 12 '12 at 17:26
add comment

1 Answer

up vote 2 down vote accepted

You need to set your /etc/hostsor C:\Windows\system32\drivers\etc\hosts(as administrator) to reflect the "subdomain". So add 127.0.0.1 dev.localhostto either file (depending on your platform).

However it might be that "localhost" as is is somewhat special in terms of a domain name resolution as it might not work as a domain. So instead you can put something like mylan.localas server name and dev.mylan.local as subdomain. (you can basically use everything you want there)

And in the end, don't forget to reload Apache with apache2ctl restart as it needs to reload its config.

share|improve this answer
    
It appears that localhost was indeed the problem. dev.local works exactly as expected –  Obi-wan Jacobi Mar 12 '12 at 17:39
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.