Debian上的VirtualHosts无法正常工作

我已经安装了debian 6挤压本地服务器。 但我无法获得虚拟主机的工作。 我想设置多个虚拟主机,但我只是从一个开始。

我禁用了默认的apache虚拟主机

a2dissite default 

设置虚拟主机和目录/etc/apache2/sites-available/test.local

 <VirtualHost *:80> ServerAdmin [email protected] 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> 

我启用了该网站

 a2ensite test.local 

重新启动服务器

 /etc/init.d/apache2 restart 

将其添加到/ etc / hosts

 192.168.1.60 test.local 

当我浏览到test.local,我只是得到一个服务器找不到错误。 我也清除了所有的cookies。 它只工作,如果我只是去192.168.1.60。

另外我在/etc/apache2/apache2.conf中configuration了apache2.conf

 Include ports.conf 

/etc/apache2/ports.conf中的ports.conf有

 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> 

我错过了什么?

“找不到服务器”意味着一个名称parsing问题,只有在使用IP时才能正常工作。

请记住,对主机文件的修改仅适用于本地系统,因此您需要从已进行修改的系统进行浏览。

如果你这样做,我会怀疑你对主机文件的修改并不坚持 – 你是否以root身份进行更改,并且在保存文件时是否存在任何问题?