linux - nginx permission denied 错误获取

标签 linux nginx redhat

由于某些原因,我在使用 nginx 和 rhel6 读取文件时遇到权限被拒绝的错误,这是我的日志文件输出

  tail -f /var/log/nginx/ph-repo.error.log

日志说

 "/opt/nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm" failed (13: Permission denied), client: 10.20.5.236, server: my-repo, request: "GET /nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm HTTP/1.1", host: "my-repo"

当我检查文件的权限时,它是 777

[root@my-repo]# ls -l nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
-rwxrwxrwx. 1 root root 360628 Oct 23 02:59 nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm

nginx进程也以root身份运行

[root@ph-repo]# ps -elf | grep nginx
1 S root      1527     1  0  80   0 - 11195 rt_sig 09:48 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
5 S root      1528  1527  0  80   0 - 11378 ep_pol 09:48 ?        00:00:00 nginx: worker process
0 S root      3062  2258  0  80   0 - 25827 pipe_w 10:52 pts/1    00:00:00 grep nginx

ACL

[root@my-repo]# getfacl nginx
# file: nginx
# owner: root
# group: root
user::rwx
group::rwx
other::rwx

[root@my-repo]# getfacl nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
# file: nginx/nginx-1.8.0-1.el6.ngx.x86_64.rpm
# owner: root
# group: root
user::rwx
group::rwx
other::rwx

我不确定这里发生了什么问题,请有人帮我解决这个问题

最佳答案

你的问题主要是文件的所有者,

su
cd /var/www
sudo chown www-data:www-data -R *

这是将文件放在与 nginx/apache 相同的用户下,应该可以解决您的问题

关于linux - nginx permission denied 错误获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34316513/

相关文章:

regex - HAProxy 和 URL 重写配置

linux - 使用 root 的 SSH 密码脚本

php - centos中通过php-fpm运行不同版本的php

linux - 如何监控和记录 mt apache 网络服务器的 session

git - 从 RHC 中删除 Openshift 服务器

c - 如何查找进程是否在 C 中运行?

c - 用C获取我机器的点分十进制IP地址?

linux - 按编号顺序创建第一个不存在的文件

linux - Kubernetes kuberadm 不使用代理

Django + uwsgi + nginx 重定向到默认页面 "Welcome to NGINX"