詳解Nginx 13: Permission denied 解決方案


這篇文章主要介紹了詳解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 http://www.iis7.com/a/lm/vpsdq/

發現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,就可以正常訪問網站了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM