>  기사  >  백엔드 개발  >  Apache提示You don't have permission to access / on this server怎么解决?

Apache提示You don't have permission to access / on this server怎么解决?

PHPz
PHPz원래의
2016-06-13 11:59:195142검색

Apache提示You don't have permission to access / on this server怎么解决?

Apache提示You don't have permission to access / on this server问题的解决

测试时遇到将一本地目录设置为一apache的虚拟主机,在httpd-vhosts.conf文件中进行简单设置,然后在hosts文件中将访问地址指向本地,启动apache,进行访问,却出现了You don’t have permission to access / on this server的提示。

baidu了一下,原来是因为我的虚拟主机目录为非apache安装目录下的htdocs,所以违反了apache对默认对网站根访问权限。

apache的默认虚拟主机根目录地址为…/Apache Software Foundation/Apache2.2/htdocs 目录下,需要对httpd.conf文件进行修改才能指向其他目录。

在httpd.conf文件下找到这段:

DocumentRoot "C:/Program Files/Apache24/htdocs"

上面这个地址是你服务器的根目录

接下来为你的根目录配置访问权限

<Directory "C:/Program Files/Apache24/htdocs">
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>

然后重启apache,就ok了。

如果要配置自己的根目录,则将DocumentRoot中的地址换为你自己的地址,并为给该目录相应权限。

更多相关知识,请访问 PHP中文网!!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.