lqisgod
V2EX  ›  科技

诡异的 Forbidden You don't have permission to access / on this server.问题

By lqisgod at 2016 年 3 月 1 日 · 3752 次点击

最近在 centos 上撸inews这套 php 模板
在 apache 配置里填写如下:

<VirtualHost *:80>
DocumentRoot "/root/inews"
ServerName ip
SetEnv PAGON_ENV production
<Directory /root/inews>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

但是访问 ip 后显示 Forbidden You don't have permission to access / on this server.
于是查阅了stackoverflow这篇里的解决方法

  1. 把 httpd.conf 中所有 require all denied 的设置都改为了 Require all granted
  2. sudo chmod 755 /root/inews

依旧会报 Forbidden You don't have permission to access / on this server. 求各位大神指点迷津:)

6 条回复  •  2016-03-01 13:35:42 +08:00
Strikeactor
   1
Strikeactor  
   2016 年 3 月 1 日   ❤️ 1
试试 Nginx
shiji
   2
shiji  
   2016 年 3 月 1 日
/root 默认是只有 root 用户有读写权限吧。
你的 Apache 是用包管理安装的吧? apache 的用户名是 apache
那么你可以在 shell 下面, su apache , 然后看看能不能 ls /root/inews

总之就是,你即使给 /root/inews 开放了权限,但是没有访问 /root 的权限,应该需要开启 /root 文件夹给 other 的执行权限。
shiji
   3
shiji  
   2016 年 3 月 1 日   ❤️ 1
顺便给你来一盘鸟哥的私房菜:
http://vbird.dic.ksu.edu.tw/linux_basic/0210filepermission.php
看这一章节“目录与文件之权限意义”

或者你可以试试把 /root/inews 的所有者改成 apache
ryd994
   4
ryd994  
   2016 年 3 月 1 日 via Android   ❤️ 1
不行的
除非你给 apache 用户对 /root 的 rx 权限(换我是绝对不可能给的)
Web 服务器需要整个目录层次的 rx 权限
我建议你放 srv 或者 var 下新建一个目录
如果是为了方便的话可以 ln 到 /root 下
heliumhgy
   5
heliumhgy  
   2016 年 3 月 1 日   ❤️ 1
整个路径上都要设置好权限。
lqisgod
   6
lqisgod  
OP
   2016 年 3 月 1 日
感谢大家 确实是权限问题,已搞定:)
© 2026 V2EX · 37ms · 3.9.8.5