【发布时间】:2019-10-22 22:06:22
【问题描述】:
在 CentOS7 上将 nginx 工作进程用户设置为不同于 root 时,它返回 404 not found。
在 nginx.conf 中使用 user root;
root 3776 0.0 0.1 46580 1056 ? Ss 15:28 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
root 3777 0.0 0.3 47008 3540 ? S 15:28 0:00 nginx: worker process
不能在 nginx.conf 中使用 user nginx;
root 3837 0.0 0.1 46580 1056 ? Ss 15:35 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 3838 0.0 0.3 47008 3540 ? S 15:35 0:00 nginx: worker process
开启error.log
2019/06/07 15:35:06 [crit] 3838#3838: *1 stat() "/mnt/projects/samir" failed (13: Permission denied), client: [removed], server: [removed], request: "GET / HTTP/1.1", host: "[removed]"
我需要添加什么权限?我测试了将文件夹组更改为 nginx:nginx,添加 777 权限,也测试了 755。
【问题讨论】:
-
您需要将
/mnt/projects/samir的访问权限授予 nginx 用户。还要确保它具有对父目录的读取权限,否则仅授予对samir文件夹的访问权限可能不起作用 -
好吧。有用。但是有一个问题。为什么每个文件夹都需要拥有 nginx:nginx 的所有权?不同的用户有不同的文件夹,每个用户对文件夹都有自己的所有权。
-
现在它会在该用户登录时提供
Permission denied。因为实际上用户对系统中的任何文件夹都没有任何所有权。
标签: nginx permissions centos http-status-code-404 worker-process