Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Apache logs "pcfg_openfile: unable to check htaccess file" for a site

Error(13)Permission denied: /var/www/abc/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

Short answer

Apache runs as its own user, not as you. The error means that user cannot read the .htaccess file or cannot enter one of the folders above it. Run namei on the full path, give every folder execute permission for the Apache user, and make the .htaccess file readable.

  • Applies to Apache 2.4, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Show the owner and permissions of every folder on the way to the file. The first entry that the Apache user cannot pass or read is the problem.

    namei -l /var/www/abc/.htaccess
  2. 2Match what you see, then jump to its fix

    1. 1namei shows a parent folder such as /home/user with mode rwx------ or rwxr-x---A folder above the site has no execute (search) permission for ApacheFix
    2. 2namei shows the folders are fine, but the file mode is rw------- and owner is another userThe .htaccess file itself is not readable by the Apache userFix
    3. 3Permissions look right for www-data but the files belong to another accountApache runs as a different user than you assumedFix

What does the error look like?

  • (13)Permission denied: /var/www/abc/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
  • pcfg_openfile: unable to check htaccess file

Cause 1 of 3

A folder above the site has no execute (search) permission for Apache

1Check

On a directory the execute bit is the search bit. Without it the kernel refuses to look inside, and the error code is EACCES, which is exactly (13) Permission denied.

namei -m /var/www/abc/.htaccess
ps -o user= -C apache2 | sort -u

2Fix

Give others (or the group Apache belongs to) execute on each folder in the path. Use a group when you do not want everyone to enter.

sudo chmod o+x /home/user
# or, with a group:
sudo chgrp www-data /home/user && sudo chmod g+x /home/user

3Verify

Run namei again and reload the site.

namei -m /var/www/abc/.htaccess && curl -I http://localhost/

Confirmed by man7.org

Did this fix it?

Cause 2 of 3

The .htaccess file itself is not readable by the Apache user

1Check

Apache switches to the user set by the User directive to serve requests, so that user needs read permission on the file. List the file with owner and mode.

ls -l /var/www/abc/.htaccess
ps -o user= -C apache2 | sort -u

2Fix

Make the file readable and keep it writable only by its owner.

sudo chmod 644 /var/www/abc/.htaccess

3Verify

Request the site again. The error no longer appears in the log.

curl -I http://localhost/

Confirmed by httpd.apache.org

Did this fix it?

Cause 3 of 3

Apache runs as a different user than you assumed

1Check

The ps command from the first cause shows who the worker processes run as. If a custom User or Group is set, grant access to that account, not to the default one.

ps -o user=,group= -C apache2 | sort -u

2Fix

Use the actual user and group in your chown or chgrp commands, or change User and Group in the Apache configuration, then reload.

sudo chgrp -R <apache-group> /var/www/abc
sudo systemctl reload apache2

3Verify

Run namei again and request the site.

namei -l /var/www/abc/.htaccess

Confirmed by httpd.apache.org

Did this fix it?

How do I stop it coming back?

  • Keep sites under /var/www or another path where every parent folder is readable to the web server.
  • Deploy files with a fixed owner and group so permissions do not change after uploads.
  • Check new virtual hosts with namei before the first request.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.