Linux – Apache httpd permissions

httpdlinuxpermissions

I have created a directory

/xyz/www

With the following permissions:

-rw-r--r--. 1 myuser developers

I edited my http.conf:

DocumentRoot "/xyz/www/"
<Directory "/xyz/www/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

I get 403 error: You don't have permission to access / on this server.

Looking in the logs:

(13)Permission denied: Can't open directory for index: /xyz/www/

I've tried recursively adding 777 permissions but still have the same issue.

Best Answer

What you have to do is copy the same security context /var/www/html has. To do this:

# ls -la --context /var/www/html
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t .
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t ..
-rw-r--r-- root root user_u:object_r:httpd_sys_content_t index.html

Then you have to set it to your desire DocumentRoot as follows:

# chcon -R system_u:object_r:httpd_sys_content_t /xyz/www