Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Gunicorn&x2B;尝试应用代码更改时发生Nginx内部服务器错误_Python_Django_Nginx_Gunicorn - Fatal编程技术网

Python Gunicorn&x2B;尝试应用代码更改时发生Nginx内部服务器错误

Python Gunicorn&x2B;尝试应用代码更改时发生Nginx内部服务器错误,python,django,nginx,gunicorn,Python,Django,Nginx,Gunicorn,我设置了一个VPS(django+gunicorn+nginx),显示默认的django屏幕效果很好,但在我更新了django代码并进行了所有迁移之后,我认为现在需要重新启动gunicorn来应用更改 所以我这样做了: sudo systemctl restart gunicorn 在此之后,我得到了内部服务器错误 一切都是这样安排的 gunicorn.service: [Unit] Description=gunicorn daemon After=network.targett [Se

我设置了一个VPS(django+gunicorn+nginx),显示默认的django屏幕效果很好,但在我更新了django代码并进行了所有迁移之后,我认为现在需要重新启动gunicorn来应用更改

所以我这样做了:

sudo systemctl restart gunicorn 
在此之后,我得到了
内部服务器错误
一切都是这样安排的

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
,[Errno 13]权限被拒绝:文件:/usr/lib/python2.7/socket.py行:228

unix套接字文件拥有与unix文件相同的权限;文件(
/home/thekotik/glboy/closer.sock
)当前正由gunicorn进程用户使用或不为其所有,导致
错误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_pass http://127.0.0.1:9090$request_uri;

这将避免基于unix套接字文件的权限问题。

检查日志(如果您有-Gunicorn和Nginx应自动创建日志)或在调试模式下运行以查看更多信息。@furas error:,[Errno 13]权限被拒绝:文件:/usr/lib/python2.7/socket.py行:228@furas已尝试chown thekotik/usr/lib/python2.7/socket.py chown:更改“/usr/lib/python2.7/socket.py”的所有权:不允许操作我通常使用
service gunicorn restart
应用代码更改。这对我来说很好me@Vinand附上带有问题的gunicorn服务文件,这将使其他人清楚地了解情况