我是Python Django的新手,我已经成功创建了我的应用程序,当我尝试在Ubuntu 16.04上托管我的Django应用程序时,它无法正常工作,我尝试了多种方法,并用Google进行了很多尝试,请帮助避免这种情况。
我遵循了该网址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文件以及如何创建该文件一无所知?非常感谢您的答复。
答案 0 :(得分:0)
文件'.sock'将通过正确的配置自动创建。无需手动创建。在 etc / inint / gunicorn.confi 文件
中给出绝对值exec python3venv/bin/gunicorn
应该是
exec /path/.../python3venv/bin/gunicorn