如何解决Apache安装后,访问网站出现“禁止访问”的情况

@如何解决Apache安装后,访问网站出现“禁止访问”的情况

解决vhost中“禁止访问”的403问题

各位大神好! 这是我第一次在csdn上 发表博客。本人是初学网站的菜鸟,跟着一个大神学习网站制作,在安装完成xampp之后,跟着网上的一个视频学习安装APache的虚拟机时,遇到了几个问题,用了一天的时间逐一解决了,虽然挺笨的的,但挺有成就感。

配置httpd.conf文件

如果你安装的是xampp3.2.4,那么xampp/apache/conf/下的httpd.conf文件已经将
Include conf/extra/httpd-vhosts.conf这条语句去掉注释,意味着,服务器将会调用conf/extra/httpd-vhosts.conf 文件。注意,如果你要给你的网站另开一个端口一定要在Listen 80后边换行加上你要开的端口,如Listen 8081,这样,服务器也会同时监听这个新的端口。

配置httpd-vhost.conf文件

如果只是将以下的
##<VirtualHost *:80>
##ServerAdmin [email protected]
##DocumentRoot “D:/xampp/htdocs/dummy-host2.example.com”
##ServerName dummy-host2.example.com
##ErrorLog “logs/dummy-host2.example.com-error.log”
##CustomLog “logs/dummy-host2.example.com-access.log” common
##
仅仅去掉注释,照猫画虎,你很可能会出现“禁止访问”的错误
如何解决Apache安装后,访问网站出现“禁止访问”的情况

解决方案

在这段代码的结束前,增加目录访问权限设置:
<Directory “D:/yiming/learning/resmgt”>
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory >
整个的配置如下:

<VirtualHost *:8081>
ServerAdmin [email protected]
DocumentRoot “D:/yiming/learning/resmgt”
ServerName resmgt.com
ErrorLog “logs/dummy-host2.example.com-error.log”
CustomLog “logs/dummy-host2.example.com-access.log” common
<Directory “D:/yiming/learning/resmgt”>
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
</VirtualHost>

问题解决,希望对大家有所帮助!