php 权限被拒绝:/var/www/abc/.htaccess pcfg_openfile:无法检查 htaccess 文件,确保它可读?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20627084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Permission denied: /var/www/abc/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable?
提问by PHPLover
Hi all I'm using PHP for my website and ubuntu linux on my system. I got the above error in error.log file of apache, even after configurating everything properly. I did a lot of research on this but couldn't be able to resolve the issue. Can anyone please help me in this reagard? Following is my .htaccess file in abc directory. Can anyone please help me in this regard?
大家好,我在我的网站上使用 PHP,在我的系统上使用 ubuntu linux。我在 apache 的 error.log 文件中收到了上述错误,即使在正确配置了所有内容之后。我对此进行了大量研究,但无法解决该问题。任何人都可以在这方面帮助我吗?以下是我的 .htaccess 文件abc directory。任何人都可以在这方面帮助我吗?
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName abc.org
AuthUserFile /home/abc/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/abc/public_html/_vti_pvt/service.grp
Options -Indexes
RewriteEngine On
RewriteRule ^alumni$ alumni.php
RewriteRule ^student$ student.php
RewriteRule ^view_alumni_article/view/([0-9]+)$ view_alumni_article.php?op=view&article_id=
回答by Jon Lin
Make sure that the htaccess file is readable by apache:
确保 apache 可以读取 htaccess 文件:
chmod 644 /var/www/abc/.htaccess
And make sure the directory it's in is readable andexecutable:
并确保它所在的目录是可读和可执行的:
chmod 755 /var/www/abc/
回答by Aneesh
I had the same issue when I changed the home directory of one use. In my case it was because of selinux. I used the below to fix the issue:
当我更改一次使用的主目录时,我遇到了同样的问题。就我而言,这是因为selinux. 我用下面的来解决这个问题:
selinuxenabled 0
setenforce 0
回答by jbrahy
If it gets into the selinux arena you've got a much more complicated issue. It's not a good idea to remove the selinux protection but to embrace it and use the tools that were designed to manage it.
如果它进入 selinux 领域,你就会遇到一个更复杂的问题。移除 selinux 保护并不是一个好主意,而是拥抱它并使用旨在管理它的工具。
If you are serving content out of /var/www/abc, you can verify the selinux permissions with a Zappended to the normal ls -lcommand. i.e. ls -laZwill give the selinux context.
如果您从 提供内容/var/www/abc,您可以通过Z附加到普通ls -l命令来验证 selinux 权限。即ls -laZ会给出 selinux 上下文。
To add a directory to be served by selinux you can use the semanagecommand like this. This will change the label on /var/www/abcto httpd_sys_content_t
要添加由 selinux 服务的目录,您可以使用这样的semanage命令。这会将标签更改/var/www/abc为httpd_sys_content_t
semanage fcontext -a -t httpd_sys_content_t /var/www/abc
this will update the label for /var/www/abc
这将更新标签 /var/www/abc
restorecon /var/www/abc
This answer was taken from unixmenand modified to fit this question. I had been searching for this answer for a while and finally found it so felt like I needed to share somewhere. Hope it helps someone.
该答案取自unixmen并进行了修改以适合此问题。我一直在寻找这个答案一段时间,终于找到了,所以觉得我需要在某个地方分享。希望它可以帮助某人。
回答by Umesh Patil
I have also got stuck into this and believe me disabling SELinux is not a good idea.
我也陷入了这个困境,相信我禁用 SELinux 不是一个好主意。
Please just use below and you are good,
请在下面使用,你很好,
sudo restorecon -R /var/www/mysite
Enjoy..
享受..

