安装apache遇到You don’t have permission to access this resource. 原因与解决方法

在配置PHP服务器时,遇到Apache无法进行远程HTTP请求的难题。通过修改httpd.conf和httpd-vhosts.conf文件中的Directory配置,将Require local更改为Require all granted,并允许Override,解决了问题。记得重启Apache服务以应用更改。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

给公司配置PHP服务器,用apache进行操作,遇到如标题那个问题,无法进行远程HTTP请求,解决办法如下

apach/conf/httpd.conf文件修改如下:

<Directory />
    Options FollowSymLinks
    AllowOverride all
    Require local
</Directory>

修改为:

<Directory />
    Options FollowSymLinks
    AllowOverride none
    Require all granted
</Directory>

以及下方的

DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
    Options FollowSymLinks
    AllowOverride all
    Require local
</Directory>

修改为:

DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
</Directory>

此时还是不行,被干的稀碎,参考大佬原帖:https://bbs.csdn.net/topics/390904273?list=23494857

但是他可能没提醒用户httpd-vhosts.conf也要改,路径在apach/conf/extra/httpd-vhosts.conf里面

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride all
    Require local
  </Directory>
</VirtualHost>

修改为:

# Virtual Hosts
#
<VirtualHost *:80>
  #ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride None
    Require all granted
  </Directory>
</VirtualHost>
然后重启apache,成功。

希望文章对你有帮助

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值