lqisgod
V2EX  ›  科技

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

  •  
  •   lqisgod · Mar 1, 2016 · 3442 views
    This topic created in 3737 days ago, the information mentioned may be changed or developed.

    最近在 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 replies    2016-03-01 13:35:42 +08:00
    Strikeactor
        1
    Strikeactor  
       Mar 1, 2016   ❤️ 1
    试试 Nginx
    shiji
        2
    shiji  
       Mar 1, 2016
    /root 默认是只有 root 用户有读写权限吧。
    你的 Apache 是用包管理安装的吧? apache 的用户名是 apache
    那么你可以在 shell 下面, su apache , 然后看看能不能 ls /root/inews

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

    或者你可以试试把 /root/inews 的所有者改成 apache
    ryd994
        4
    ryd994  
       Mar 1, 2016 via Android   ❤️ 1
    不行的
    除非你给 apache 用户对 /root 的 rx 权限(换我是绝对不可能给的)
    Web 服务器需要整个目录层次的 rx 权限
    我建议你放 srv 或者 var 下新建一个目录
    如果是为了方便的话可以 ln 到 /root 下
    heliumhgy
        5
    heliumhgy  
       Mar 1, 2016   ❤️ 1
    整个路径上都要设置好权限。
    lqisgod
        6
    lqisgod  
    OP
       Mar 1, 2016
    感谢大家 确实是权限问题,已搞定:)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5173 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 09:41 · PVG 17:41 · LAX 02:41 · JFK 05:41
    ♥ Do have faith in what you're doing.