Wamp下的虚拟主机报错403 Forbidden, You don't have permission to access / on this server.

时间:2022-02-22 16:55:27

经验还是得靠积累~

今儿在windows 10下配置了本地的Apache的虚拟主机(Wamp集成环境),各种错误,决定在博客里做个记录。

主要错误如下:


Forbidden

You don't have permission to access /on this server.


Apache/2.4.17 (Win32) PHP/5.6.15 Server at dev.com Port 80



错误核心

在配置文件httpd.conf里面,出现了“Deny from all”,导致访问被拒绝。

详情如下。






约定变量

D:\wamp\

D:\wamp\bin\apache\apache2.4.17\conf\httpd.conf

D:\wamp\bin\apache\apache2.4.17\conf\extra\httpd-vhosts.conf

C:\Windows\System32\drivers\etc\HOSTS

D:\project\

dev.com


完整流程

1.创建项目文件 D:\project\index.php

2.安装wamp到D:\wamp\

3.启动wamp,如果卡在橙色图标,请左击wamp托盘图标,Apache => Service administration => Install Service,再启动,不行就百度

4.复制C:\Windows\System32\drivers\etc\HOSTS到桌面,添加以下内容再复制回去: 127.0.0.1 dev.com

5.修改D:\wamp\bin\apache\apache2.4.17\conf\extra\httpd-vhosts.conf ,删掉后面两大段的实例设置,添加内容:

<VirtualHost *:80>
DocumentRoot D:/project
ServerName dev.com
ServerAlias www.dev.com
</VirtualHost>
6.修改D:\wamp\bin\apache\apache2.4.17\conf\httpd.conf,

    1) 找到并启用 LoadModule rewrite_module modules/mod_rewrite.so (删掉前面的#号即可)

    2) 找到唯一的<Directory />标签对,修改为:

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
    3) 找到并启用 Include conf/extra/httpd-vhosts.conf (删掉前面的#号即可)

    4) 在最后面插入以下内容:

<Directory "D:/project/">
Options Indexes FollowSymLinks
AllowOverride all
Order deny,allow
allow from all
</Directory>
    4) 保存文件

7.重启Wamp,搞定!

  

Wamp下的虚拟主机报错403 Forbidden, You don't have permission to access / on this server.