I have setup a local server with debian 6 squeeze. But I cannot get virtualhosts to work. I would like to setup multiple virtualhosts but I just started with one.

I disabled the default apache virtual host

a2dissite default

Setup the virtual host and directories /etc/apache2/sites-available/test.local

<VirtualHost *:80>
 ServerAdmin webmaster@test.local
 ServerName test.local
 DocumentRoot /srv/www/test.local/public_html/
 ErrorLog /srv/www/test.local/logs/error.log
 CustomLog /srv/www/test.local/logs/access.log combined

I enabled the site

a2ensite test.local

Restarted server

/etc/init.d/apache2 restart

Added it to /etc/hosts test.local

When I browse to test.local, I just get a server not found error. I have also cleared all cookies. It only works, if I just go to

Also my apache2.conf in /etc/apache2/apache2.conf has

Include ports.conf

ports.conf in /etc/apache2/ports.conf has

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
 # If you add NameVirtualHost *:443 here, you will also have to change
 # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
 # to <VirtualHost *:443>
 # Server Name Indication for SSL named virtual hosts is currently not
 # supported by MSIE on Windows XP.
 Listen 443

<IfModule mod_gnutls.c>
 Listen 443

Am I missing anything?


"Server not found" implies a name resolution issue, which is backed up by it working correctly when using just the IP.

Keep in mind that a modification to the hosts file will only work for the local system - so you'll need to be browsing from the system that's had the modification made.

If you're doing that, I'd suspect that your modification to the hosts file didn't stick - did you make the change as root, and were there any issues with saving the file?

  • Oh ok. The debian server is installed on another computer on the same network and I was browsing from another computer. So in order for it to work, I would have to browse from the computer where debian is installed, correct? Yes, I made the change as root and there were no errors. – amye Jul 31 '11 at 0:36
  • 1
    Either that or you need to add the /etc/hosts entry upon both the remote server AND the server you're using the browser upon. – user9565 Jul 31 '11 at 0:42
  • @Steve Kemp, thanks! Adding the /etc/hosts entry on both servers worked. – amye Jul 31 '11 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.