[英]Gunicorn + Nginx Internal server error while trying to apply code changes
我设置了一个VPS(django + gunicorn + nginx),并且在显示默认django屏幕时工作正常,但是在更新django代码并进行所有迁移后,我认为现在需要重新启动gunicorn才能应用更改。
所以我这样做:
sudo systemctl restart gunicorn
在此之后,我收到了Internal Server Error
所有内容均按此处设置
gunicorn.service:
[Unit]
Description=gunicorn daemon
After=network.targett
[Service]
User=thekotik
Group=www-data
WorkingDirectory=/home/thekotik/glboy
ExecStart=/home/thekotik/glboy/denv/bin/gunicorn --workers 3 --bind unix:/home/thekotik/glboy/closer.sock closer.wsgi:application
[Install]
WantedBy=multi-user.target
<class 'socket.error'>, [Errno 13] Permission denied: file: /usr/lib/python2.7/socket.py line: 228
unix套接字文件与unix文件具有相同的权限; 该文件( /home/thekotik/glboy/closer.sock
)当前被使用或未由gunicorn进程用户拥有,从而导致error 13
。
我建议使用TCP选项--bind 127.0.0.1:8000
。对于基于tcp的更改,
gunicorn.service
[Unit]
Description=gunicorn daemon
After=network.targett
[Service]
User=thekotik
Group=www-data
WorkingDirectory=/home/thekotik/glboy
ExecStart=/home/thekotik/glboy/denv/bin/gunicorn --workers 3 --bind 127.0.0.1:9090 closer.wsgi:application
[Install]
WantedBy=multi-user.target
将上述systemd服务文件用于gunicorn并将nginx中的proxy选项更改为
proxy_pass http://127.0.0.1:9090$request_uri;
这样可以避免基于unix套接字文件的权限问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.