C:\wamp\vhosts 文件夹现在是一个已失效的概念,您应该使用原始的 wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhost.conf 文件。然后在httpd.conf 文件中取消注释该文件的包含,它靠近httpd.conf 文件的底部。
另外,您还没有向 Apache 提供说明,告诉它谁可以访问该站点。
您创建的虚拟主机定义中也存在一些错误。您应该为 localhost 以及您自己的新站点添加 VHOST 定义。
DocumentRoot "c:/wwwroot/app/App/www/app.html" 也是错误的,它应该只识别文件夹而不包括页面名称,同上<Directory...> 参数。
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All
#If APACHE2.4
# Require local
#If APACHE2.2
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin me@website.com
DocumentRoot "c:/wwwroot/app/App/www"
ServerName app.myapps.local
<Directory "c:/wwwroot/app/App/www">
AllowOverride All
Options +Indexes
#If APACHE2.4
# Require local
#If APACHE2.2
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
ErrorLog "c:/wwwroot/app/log/error.log"
CustomLog "c:/wwwroot/app/log/access.log" common
LogLevel debug
SetEnv MANGO_ENVIRONMENT ME
# as you have moved the Apache logs it may also be a good idea
# to move the php error log as well.
php_value error_log "c:/wwwroot/app/log/php_error.log"
</VirtualHost>
您现在必须在 C:\windows\system32\drivers\etc\hosts 文件中为每个虚拟主机创建一个条目,以便 windows 知道在哪里可以找到您在 ServerName 参数中创建的域,就像您所做的那样,但添加IPV4 地址127.0.0.1 和IPV6 地址::1。
#The first 2 line should already be in here
127.0.0.1 localhost
::1 localhost
127.0.0.1 app.myapps.local
::1 app.myapps.local
完成此更改后,您可以从命令窗口重新加载 Windows DNS 缓存,这也必须使用 Run as Administrator 菜单选项启动。
net stop dnscache
net start dnscache
然后您应该准备好重新加载 Apache 以获取所有这些更改。
如果遇到问题,请记住 Apache 在实际打开自己的错误日志之前写入 Windows 事件日志。如果您在 httpd.conf 文件或该文件中包含的任何文件(如 wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhosts.conf)中有错误,它将识别发现错误的行号。