Apache httpd 权限

DD.*_*DD. 5 linux permissions httpd

我创建了一个目录

/xyz/www
Run Code Online (Sandbox Code Playgroud)

具有以下权限:

-rw-r--r--. 1 myuser developers
Run Code Online (Sandbox Code Playgroud)

我编辑了我的 http.conf:

DocumentRoot "/xyz/www/"
<Directory "/xyz/www/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

我收到 403 错误: You don't have permission to access / on this server.

查看日志:

(13)Permission denied: Can't open directory for index: /xyz/www/
Run Code Online (Sandbox Code Playgroud)

我试过递归添加 777 权限,但仍然有同样的问题。

bor*_*roz 15

您需要做的是复制/var/www/html 具有的相同安全上下文。去做这个:

# 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
Run Code Online (Sandbox Code Playgroud)

然后你必须将它设置为你想要的 DocumentRoot 如下:

# chcon -R system_u:object_r:httpd_sys_content_t /xyz/www
Run Code Online (Sandbox Code Playgroud)