VirtualHost指向相同的DocumentRoot?

出于某种原因,domain1.org和domain2.org都是直接进入/ var / www有没有什么我错过了? Apache2错误日志也是干净的? 我只是不明白。 这应该是一个简单的虚拟

<VirtualHost *:80> ServerName domain1.org ServerAdmin webmaster@localhost DocumentRoot /var/www/ <Directory /var/www/> DirectoryIndex index.php Options -Indexes FollowSymLinks MultiViews AllowOverride All 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 debug CustomLog /var/log/apache2/access.log combined </VirtualHost> <VirtualHost *:80> ServerName domain2.org ServerAdmin webmaster@localhost DocumentRoot /var/www/wordpress-1/ <Directory /var/www/wordpress-1/ > DirectoryIndex index.php Options -Indexes FollowSymLinks MultiViews AllowOverride All 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 debug CustomLog /var/log/apache2/access.log combined </VirtualHost> 

虚拟主机定义没有出现任何问题。 你记得在更新configuration文件后重新启动Apache吗? 你不会说你正在使用哪个操作系统,所以很难取得进展。 你应该看看输出

 /usr/sbin/apache2ctl -S 

要么

 /usr/sbin/httpd -S 

这将显示您的apache知道的虚拟主机,并且还将指示是否启用了基于名称的虚拟主机,例如

  /usr/sbin/apache2ctl -S VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server test1.lan (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost test1.lan (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost centos1.lan (/etc/apache2/sites-enabled/000-default:94) port 80 namevhost host1.test.lan (/etc/apache2/sites-enabled/subhosts:41) port 80 namevhost host2.test.lan (/etc/apache2/sites-enabled/subhosts:49) Syntax OK 

如果你没有*:80 is a NameVirtualHost那么你将需要启用它与一个

 NameVirtualHost *:80 

指令在VirtualHost定义之前。