Apache Httpd设置权限

Apache Httpd设置权限,apache,.htaccess,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>

我看到了很多关于这个的问题,但是没有什么能解决我的问题。 我在/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>
然后,当我尝试访问时,我得到:

权限被拒绝:[客户端127.0.0.1:57908]AH00529: /var/www/site/web/.htaccess pcfg_openfile:无法检查 htaccess文件,确保它可读并且 “/var/www/site/web/”是可执行文件,请参考:

因此,我设置了644对.htaccess:

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>
DirectoryIndex app.php
选项-多视图
重新启动发动机
RewriteCond%{REQUEST_URI}:$1^(/.+)/(.*):\2$
重写规则^(.*)-[E=基:%1]
RewriteCond%{HTTP:Authorization}。
重写规则^-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
RewriteCond%{ENV:REDIRECT_STATUS}^$
重写规则^app\.php(?:/(.*)|$)%{ENV:BASE}/$1[R=301,L]
RewriteCond%{REQUEST_FILENAME}-f
重写规则^-[L]
重写规则^%{ENV:BASE}/app.php[L]
#当mod_rewrite不可用时,我们指示临时重定向
#将起始页显式地发送到前端控制器,以便网站
#生成的链接仍然可以使用。
重定向匹配302^/$/app.php/
#不能改为使用RedirectTemp

有人能帮我理解我错在哪里吗?谢谢。

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

SELinux正在阻止httpd读取文件

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

setsebool -P httpd_read_user_content 1
setsebool -P httpd_read_user_content 1