【发布时间】:2018-12-04 03:50:42
【问题描述】:
我是 Python Django 的新手,我已经成功创建了我的应用程序,当我尝试在 Ubuntu 16.04 上托管我的 Django 应用程序时,它无法正常工作我尝试了多种方法并用谷歌搜索了很多,请帮助摆脱这种情况。
我关注了这个 URL How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 我已经正确完成了所有设置,但我仍然没有成功。在这里,我分享必要的文件供您参考,如果我错过了什么,请告诉我。
etc/nginx/site-available
server {
listen *:91;
server_name ip-address;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/iradmin/django/scm;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/iradmin/django/scm/scm.sock;
}
}
etc/inint/gunicorn.confi
decription "Gunicorn application server handling scm"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid iradmin
setgid www-data
chdir /home/iradmin/django/scm/
exec python3venv/bin/gunicorn --workers 3 --bind unix:/home/iradmin/django/scm/scm.sock scm.wsgi:application
当我完成所有部署步骤后,我在 nginx/error.log 中遇到以下错误
2018/06/25 18:59:50 [crit] 32640#32640: *8 connect() to unix:/home/iradmin/django/scm/scm.sock failed (2: No such file or directory) while connecting to upstream, client: 10.200.101.124, server: ip-address, request: "GET / HTTP/1.1", upstream: "http://unix:/home/iradmin/django/scm/scm.sock:/", host: "10.200.101.227:91"
2018/06/25 18:59:52 [crit] 32640#32640: *10 connect() to unix:/home/iradmin/django/scm/scm.sock failed (2: No such file or directory) while connecting to upstream, client: 10.200.101.124, server: ip-address, request: "GET / HTTP/1.1", upstream: "http://unix:/home/iradmin/django/scm/scm.sock:/", host: "10.200.101.227:91"
[ N 2018-06-25 19:02:33.5097 32620/T4 age/Cor/CoreMain.cpp:1068 ]: Checking whether to disconnect long-running connections for process 32725, application /var/www/pyraMID (production)
独角兽状态
root@iradmin-OptiPlex-3040:/etc/init# sudo service gunicorn status
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-06-25 19:15:22 IST; 33min ago
Main PID: 5226 (code=exited, status=216/GROUP)
Jun 25 19:15:22 iradmin-OptiPlex-3040 systemd[1]: Started gunicorn daemon.
Jun 25 19:15:22 iradmin-OptiPlex-3040 systemd[1]: gunicorn.service: Main process exited, code=exited, status=216/GROUP
Jun 25 19:15:22 iradmin-OptiPlex-3040 systemd[1]: gunicorn.service: Unit entered failed state.
Jun 25 19:15:22 iradmin-OptiPlex-3040 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
我尝试了几种方法,但我仍然不知道 .sock 文件以及如何创建它?非常感谢您的回复。
【问题讨论】: