详解Nginx 13: Permission denied 解决方案
今天在用uwsgi+nginx在部署flask应用时,遇到502的错误,vim /var/log/nginx/error.log
查看nginx的错误日志,提示如下错误信息:
2018/07/22 00:46:36 [crit] 15890#15890: *74 connect() to unix:/root/jianshuvue/jianshu.sock failed (13: permission denied) while connecting to upstream, client: 120.42.13.98, server: jianshu.weiweiblog.cn, request: "get /favicon.ico http/1.1", upstream: "uwsgi://unix:/root/jianshuvue/jianshu.sock:", host: "jianshu.weiweiblog.cn", referrer: "http://jianshu.weiweiblog.cn/jianshu/67eb7ed414d3"
permission denied,一看就知道是权限出了问题,通过ps -ef | grep nginx
,查看nginx的进程信息:
root 15889 1 0 00:01 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 15890 15889 0 00:01 ? 00:00:00 nginx: worker process
root 16795 15654 0 00:48 pts/3 00:00:00 grep --color=auto nginx
发现nginx进程的用户是nginx,而我们创建/root/jianshuvue/jianshu.sock文件的用户是root,因此,只要把nginx的进程user改为root即可,vim /etc/nginx/nginx.conf:
# user www-data; user root; worker_processes auto; pid /run/nginx.pid;
之后,/etc/init.d/nginx restart
重启nginx,就可以正常访问网站了。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
推荐阅读
-
Nginx应对Permission denied和File not found的配置
-
Nginx报403 forbidden错误 (13: Permission denied)的解决办法
-
Nginx中报错:Permission denied与Connection refused的解决
-
centOS环境的nginx+unicorn访问socket文件总是报(13 permission denied)
-
nginx 出现failed (13: Permission denied)
-
nginx在宿主机可以访问但在外网无法访问日志报Permission denied while connecting to upstream
-
详解Nginx 13: Permission denied 解决方案
-
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/itsdangerous' C
-
Python中Permission denied的解决方案
-
使用tempfile.NamedTemporaryFile()报错PermissionError: [Errno 13] Permission denied