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
</VirtualHost>

I enabled the site

a2ensite test.local

Restarted server

/etc/init.d/apache2 restart

Added it to /etc/hosts

192.168.1.60 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 192.168.1.60.

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>

<IfModule mod_gnutls.c>
 Listen 443
</IfModule>

Am I missing anything?

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

"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?

link|improve this answer
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. – Steve Kemp 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
feedback

Your Answer

 
or
required, but never shown

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