Httpd设置权限

时间:2016-03-19 08:07:55

标签: apache .htaccess

我看到了很多关于此的问题,但没有解决我的问题。 我在/ var / www / site中有一个指向/ home / user / Development / site的符号链接。 这是我的虚拟主持人:

VirtualHost *:80>
    ServerName site.localhost
    ServerAlias site.localhost
    DocumentRoot /var/www/site/web
    <Directory /var/www/site/web>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from All
        <IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule ^(.*)$ /app.php [QSA,L]
        </IfModule>
    </Directory>
</VirtualHost>

然后我设置父目录的权限,所以:

chmod o+x /home /home/user /home/user/Development /home/user/Development/site

然后,当我尝试访问http://site.localhost时,我得到:

  

权限被拒绝:[client 127.0.0.1:57908] AH00529:   /var/www/site/web/.htaccess pcfg_openfile:无法检查   htaccess文件,确保它是可读的   &#39; /无功/网络/网站/网页/&#39;是可执行的,引用者:   http://site.localhost/

所以我为.htaccess设置了644权限:

chmod 664 /home/user/Development/site/web/.htaccess

但我仍然继续收到同样的错误。

这是我的.htaccess

DirectoryIndex app.php

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{HTTP:Authorization} .
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    RewriteRule ^ %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the start page to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>

有人可以帮我理解我错在哪里吗?感谢。

1 个答案:

答案 0 :(得分:0)

我找到了解决这个问题的方法,也许可以帮助别人 问题是

  

SELinux阻止httpd对文件进行读取访问...

所以要解决这个问题,只需将httpd_read_user_content设置为1:

setsebool -P httpd_read_user_content 1
相关问题