Permission denied: /var/www/abc/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable?
Solution 1
Make sure that the htaccess file is readable by apache:
chmod 644 /var/www/abc/.htaccess
And make sure the directory it's in is readable and executable:
chmod 755 /var/www/abc/
Solution 2
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:
selinuxenabled 0
setenforce 0
Solution 3
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.
If you are serving content out of /var/www/abc
, you can verify the selinux permissions with a Z
appended to the normal ls -l
command. i.e. ls -laZ
will give the selinux context.
To add a directory to be served by selinux you can use the semanage
command like this. This will change the label on /var/www/abc
to httpd_sys_content_t
semanage fcontext -a -t httpd_sys_content_t /var/www/abc
this will update the label for /var/www/abc
restorecon /var/www/abc
This answer was taken from unixmen and 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.
PHPLover
Updated on July 09, 2022Comments
-
PHPLover almost 2 years
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?# -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=$1
-
Rohit Gupta almost 9 yearsI has the same issue and changing the permissions as above made it work. However, I am not happy about the root dir being
755
. When I make it751
, it seems to work. Is this going to stuff something up ? -
Buttle Butkus almost 9 yearsI believe there are exceptions to this working. If you have suphp and/or suexec, you may get an additional error if your files are writable by group. Correct me if I'm wrong.
-
Segfault about 8 yearsI had the same problem and instead of disabling selinux I found that
sudo restorecon -R <path to site>
was enough to resolve the problem. -
Subrata Sarkar over 7 years+1 for short and simple yet the most effective solution. I got totally screwed up with the error but your solution rocks!
-
aequalsb about 7 yearsAnessh's solution worked for me... because all the other solutions above rely on
selinux
NOT being active -- permission problems are simply permission problems. but those solutions are meaningless if selinux is blocking everything (same withrestorecon
). problems on my CentOS 6 LAN web server was solved by disablingselinux
-- until a power failure struck and revealed selinux settings were not saved without editing the conf file. to save selinux settings during rebootsvi /etc/sysconfig/selinux
find and change the lineSELINUX=enabled
toSELINUX=disabled
reboot your MACHINE -
Admin over 6 yearsSolved my problem.
-
Admin over 6 yearsIt did not FIXED my problem.
-
jbrahy over 5 yearsTry yum install policycoreutils-python
-
jbrahy over 5 yearsYou can always find the package to install using whatprovides like this. $yum whatprovides /usr/sbin/semanage
-
Scott over 5 yearsNot having any luck with this on CentOS 7. Checked permissions, executes, ran semanage/restorecon as described. Still getting the error
-
jbrahy over 5 yearsHave you rebooted? Might be something hanging.
-
gdm about 5 yearsthis is the second right answer if the first one not works.
-
gdm over 2 yearsif the file permissions are ok, this is the right solution in redhat like distribution
-
Roberto Manfreda almost 2 yearsFor me, in a k8s env, running the first
chmod 644 .htaccess
was enough!