【发布时间】:2014-07-06 20:13:21
【问题描述】:
我正在尝试设置虚拟 wamp localhost。
本地主机
根文件夹:c:\wamp\www
mysite.local
根文件夹:c:\wamp\site2
已经采取了各种步骤:从文件“httpd.conf”中删除#
#Include conf/extra/httpd-vhosts.conf
在 httpd-vhosts.conf 中添加:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/site2"
ServerName mysite.local
<directory "c:/wamp/site2">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
在 hosts 文件中添加:
127.0.0.1 mysite.local
问题是,无论哪种情况,我都通过 localhost 或 mysite.local 访问 www 根文件夹。有什么解决办法吗?
【问题讨论】:
-
更改任何 httpd 配置文件后是否要重新启动 Apache?
-
是的。甚至重新启动整个窗口 :)
-
您确定您正在编辑实际使用的 httpd.conf 吗?
-
Wamp>bin>apache>apache 2.4.9>conf> httpd.conf。是的,我正在编辑它。
-
我只能告诉你,你所描述的设置在我的机器上运行良好。您的虚拟主机设置很好,您的主机文件也很好。检查在 c:\wamp\site2 中重定向的 .htaccess 文件。尝试使用一些明显错误的语法破坏虚拟主机配置文件,确保 Apache 在它被破坏时实际上不会启动 - 这是确认您拥有正确文件的最佳方法。确保主 httpd.conf 中没有关于文档根目录的有趣规则。