Hiển thị các bài đăng có nhãn AH00132. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn AH00132. Hiển thị tất cả bài đăng

[CentOS 7 Apache]: Permission denied: file permissions deny server access

 https://techglimpse.com/apache-webserver-permission-denied-error/

[CentOS 7 Apache]: Permission denied: file permissions deny server access

Updated on March 15, 2022

Whenever I configure Apache on CentOS 7, most of the time I get “(13) Permission denied: file permissions deny server access” error as below:

[Fri Nov 12 06:29:24.901157 2021] [core:error] [pid 8287] (13)Permission denied: [client 192.168.10.12:15979] AH00132: file permissions deny server access: /var/www/html/admin/images/logo.png

How to fix file permissions deny server access in Apache

Step 1: Check for the below Apache configuration which will block access to all files and URLs.

<Directory />
     Order deny,allow
     Deny from all
 </Directory>

Instead, it should be like:

<Directory />
     Order allow,deny
     Allow from all
 </Directory>

Step 2: Check Read/Write Permissions of your website’s root folder and files required by Apache. To provide permissions for Apache to read/write to the files/folders, run the below command:

# chmod -R 755 /var/www/html
-R option in the above command

will recursively update the user permissions of all files & folders in your webite’s root location.

Step 3: Check for the website’s root folder/file ownership. The ownership should be of Apache(www-data or apache). First, find out the user used by Apache process on your system by the following command:

# egrep -iw --color=auto '^user|^group' /etc/httpd/conf/httpd.conf

or

# ps aux | egrep '([a|A]pache|[h|H]ttpd)' | awk '{ print $1}' | uniq | tail -1

Now change the ownership accordingly using the below command:

# chown -R www-data:root /var/www/html

or

# chown -R apache:root /var/www/html

Step 4: Check for SELinux (Security-Enhanced Linux). You may need to use chcon command to set the security context of your website’s root directory as below:

# chcon -R -h -t httpd_sys_content_t /var/www/html

Fixing Apache (13)Permission denied: access to / 403 Forbidden

 https://www.petefreitag.com/item/793.cfm

If Running Security Enhanced Linux (SELinux)

Another possibility for this error is that you are running SELinux (Security Enhanced Linux), inwhich case you need to use chcon to apply the proper security context to the directory. One easy way to do this is to copy from a directory that does work for example /var/www/

chcon -R --reference=/var/www /path/to/webroot

Every so often I run into a 403 Forbidden response when I'm setting up something in Apache, checking the log files will yield something like:

(13)Permission denied: access to /

There are a few things that could be the problem:

Make sure it's not denied by Apache

Most apache Configurations have something like this in there:

<Directory />
    Order deny,allow
    Deny from all
</Directory>

The above will block access to all files. You should also see something like this:

<Directory /path/to/webroot>
    Order allow,deny
    Allow from all
</Directory>

So if you have created a VirtualHost or an Alias that does not fall under this /path/to/webroot apache will have denied access to it. The solution in that case is to add another Directory entry in your httpd.conf to allow access to that directory.

Make sure Apache has Read, Execute Permissions

The next thing to check is that Apache has read and execute permission (rx) on directories and read permission on files. You can run chmod 750 /dir (to give -rwxr-x--- permission) or chmod 755 /dir (to give -rwxr-xr-x permission), etc.

Make sure that the Directory Above has Execute Permission

This is the one that tends to get me. Suppose you are creating an Alias like this:

Alias /foo /tmp/bar/foo

Now you have made sure that apache can read and execute /tmp/bar/foo by running chmod 755 /tmp/bar/foo, but you also need to give Apache execute permission to /tmp/bar/ otherwise it cannot traverse the sub directory foo.

anti-pattern là gì

  Trong công nghệ và lập trình, Anti-pattern (mẫu phản diện) là những giải pháp bề ngoài có vẻ hiệu quả để giải quyết một vấn đề phổ biến, ...