1. 修改httpd-vhosts.conf文件
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:\wamp64\www\laravel\public"
ServerName laravel.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\wamp64\www\laravel\public">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
PS:文件位于C:\wamp64\bin\apache\apache2.4.17\conf\extra文件夹
2. 修改httpd.conf文件
文件位置是C:\wamp64\bin\apache\apache2.4.17\conf
在DocumentRoot "C:/wamp64/www/"下找到Diretory行并修改为:
<Directory />
AllowOverride all
Require all granted
</Directory>
找到Files ".ht*"行,修改为:
<Files ".ht*">
Require all granted
</Files>
找到Directory "C:/wamp64/cgi-bin"行并修改为:
<Directory "C:/wamp64/cgi-bin">
AllowOverride all
Options None
Require all granted
</Directory>
找到Virtual hosts,将其打开:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
3. 更新host文件
在hosts文件添加:192.168.x.x laravel.dev(根据自己情况填写)
重启wamp服务器后,在浏览器输入laravel.dev应该就可以访问了,如果不行,试试将服务器的防火墙关闭看看
上面的方式虽然方便了局域网访问,但是也导致了localhost用不了,但是数据库http://localhost/phpmyadmin/还是可以访问的
以上内容有冗余或者不正确的地方,欢迎大家讨论
2016-7-26更新
如果想要新添加一个站点,可以直接在httpd-vhosts.conf下面添加一个虚拟机配置就可以了:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:\wamp64\www\blog\public"
ServerName blog.dev
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\wamp64\www\blog\public">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
2016-9-8更新
注意启用了虚拟机配置以后,就不能像一开始一样访问localhost了,需要重新配置,具体如下
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "C:\wamp64\www"
ServerName localhost
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\wamp64\www">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
Apache
登陆发表评论