为什么Apache服务默认?

我不断添加更多的虚拟主机,并启用它们,但所有的网站总是对网站上的默认虚拟主机进行操作

这里是默认的样子与我只是为了安全原因改变IP

<VirtualHost 167.889.88.88:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> 

这是我另一个我命名some-site.net

  <VirtualHost *:80> ServerName some-site.net DocumentRoot "/var/www/vhosts/somesite.com/http/" <Directory "/var/www/vhosts/somesite.com/http/"> AllowOverride all Options -MultiViews </Directory> </VirtualHost> 

并打开我的这个命令

 sudo a2ensite some-site.net Enabling site some-site.net. Run '/etc/init.d/apache2 reload' to activate new configuration! 

然后我重新加载

 /etc/init.d/apache2 reload * Reloading web server config apache2 ...done. 

但是当我访问urlsome-site.net我得到的默认虚拟主机的索引页…我做错了什么

首先猜测,你需要在你的httpd.conf文件中使用NameVirtualHost语句。 此外,作为一个健全的检查,我假设你有正确的块?

你运行apachectl -S时会得到什么?

在您的第一个块中,您没有指定ServerName,并且Apache将传入请求与IP匹配。 问题是混合使用基于IP和名称的虚拟服务器configuration。

为了进一步排除这个问题,你的虚拟服务器指令中的一个ServerName伪指令如下所示。

VirtualHost 167.889.88.88:80

/etc/hosts文件中添加以下行:

 localhost some-site.net