4

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
2
  • What was the error? Can you edit your question to include the output from apache2ctl -S? Mar 12, 2012 at 17:02
  • There is no error, it just doesn't route to the expected folder. I posted the results of apache2ctl -S
    – jebriggsy
    Mar 12, 2012 at 17:26

1 Answer 1

4

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.

1
  • It appears that localhost was indeed the problem. dev.local works exactly as expected
    – jebriggsy
    Mar 12, 2012 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .