V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lqisgod
V2EX  ›  科技

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

  •  
  •   lqisgod · 2016-03-01 02:34:51 +08:00 · 2541 次点击
    这是一个创建于 2968 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近在 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-03-01 02:38:34 +08:00   ❤️ 1
    试试 Nginx
    shiji
        2
    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
        3
    shiji  
       2016-03-01 03:53:40 +08:00   ❤️ 1
    顺便给你来一盘鸟哥的私房菜:
    http://vbird.dic.ksu.edu.tw/linux_basic/0210filepermission.php
    看这一章节“目录与文件之权限意义”

    或者你可以试试把 /root/inews 的所有者改成 apache
    ryd994
        4
    ryd994  
       2016-03-01 05:41:36 +08:00 via Android   ❤️ 1
    不行的
    除非你给 apache 用户对 /root 的 rx 权限(换我是绝对不可能给的)
    Web 服务器需要整个目录层次的 rx 权限
    我建议你放 srv 或者 var 下新建一个目录
    如果是为了方便的话可以 ln 到 /root 下
    heliumhgy
        5
    heliumhgy  
       2016-03-01 13:30:34 +08:00   ❤️ 1
    整个路径上都要设置好权限。
    lqisgod
        6
    lqisgod  
    OP
       2016-03-01 13:35:42 +08:00
    感谢大家 确实是权限问题,已搞定:)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5426 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:19 · PVG 17:19 · LAX 02:19 · JFK 05:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.