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

2016-03-01 02:34:51 +08:00
 lqisgod

最近在 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. 求各位大神指点迷津:)

2550 次点击
所在节点   科技
6 条回复
Strikeactor
2016-03-01 02:38:34 +08:00
试试 Nginx
shiji
2016-03-01 03:48:04 +08:00
/root 默认是只有 root 用户有读写权限吧。
你的 Apache 是用包管理安装的吧? apache 的用户名是 apache
那么你可以在 shell 下面, su apache , 然后看看能不能 ls /root/inews

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

或者你可以试试把 /root/inews 的所有者改成 apache
ryd994
2016-03-01 05:41:36 +08:00
不行的
除非你给 apache 用户对 /root 的 rx 权限(换我是绝对不可能给的)
Web 服务器需要整个目录层次的 rx 权限
我建议你放 srv 或者 var 下新建一个目录
如果是为了方便的话可以 ln 到 /root 下
heliumhgy
2016-03-01 13:30:34 +08:00
整个路径上都要设置好权限。
lqisgod
2016-03-01 13:35:42 +08:00
感谢大家 确实是权限问题,已搞定:)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/260066

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX