nginx 读取文件 permission denied
Posted pclover11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx 读取文件 permission denied相关的知识,希望对你有一定的参考价值。
nginx 是在root用户下安装的,静态网页的目录/var/www/html/ 目录下的内容所有者也是root 用户,按照 nginx配置文件中location说明 配置静态文件访问地址。
使用网址访问后出现错误日志显示如下
root@localhost:/etc/nginx# more /var/log/nginx/error.log 2018/07/24 11:06:05 [error] 17823#17823: *21 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:06:06 [error] 17823#17823: *21 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:06:16 [error] 17823#17823: *23 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:06:16 [error] 17823#17823: *23 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:06:22 [error] 17823#17823: *25 directory index of "/var/www/html/show/project/" is forbidden, client: 101.228.94.31, server: _, request: "GET /show/project/ H TTP/1.1", host: "45.78.33.187" 2018/07/24 11:06:22 [error] 17823#17823: *25 directory index of "/var/www/html/show/project/" is forbidden, client: 101.228.94.31, server: _, request: "GET /show/project/ H TTP/1.1", host: "45.78.33.187" 2018/07/24 11:10:02 [error] 17823#17823: *30 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:10:02 [error] 17823#17823: *30 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:30:10 [emerg] 17956#17956: invalid number of arguments in "root" directive in /etc/nginx/sites-enabled/default:47 2018/07/24 11:31:56 [notice] 17960#17960: signal process started 2018/07/24 11:32:02 [error] 17961#17961: *38 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187" 2018/07/24 11:32:03 [error] 17961#17961: *38 open() "/var/www/html/show/project/test1.html" failed (13: Permission denied), client: 101.228.94.31, server: _, request: "GET /show/project/test1.html HTTP/1.1", host: "45.78.33.187"
修改配置文件的 user 配置,改为 root,默认位置是 /etc/nginx/nginx.cnf。
修改好后重启nginx,使用命令如下
nginx -s reload
重新访问页面正常了。
以上是关于nginx 读取文件 permission denied的主要内容,如果未能解决你的问题,请参考以下文章
docker启动容器报permission denied错误处理
ZipArchive::close(): 创建临时文件失败: Permission denied nginx
Phonegap 地理位置 PERMISSION_DENIED
Nginx错误:(13: Permission denied) while reading upstream