Zol*_*oom 9 python django nginx
我尝试在Ubuntu服务器16.04上的Django + Supervisor + NGINX中部署我的网站.
这是我的.conf(主管):
[program:sitepro]
command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
user = user
autostart = true
autorestart = true
Run Code Online (Sandbox Code Playgroud)
我的NGINX配置文件:
server {
listen 80;
server_name .mywebsite.fr;
charset utf-8;
root /home/user/sitepro/site/sitepro;
access_log /home/user/sitepro/site/logs/nginx/access.log;
error_log /home/user/sitepro/site/logs/nginx/error.log;
location /static {
alias /home/user/sitepro/site/static;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_pass http://127.0.0.1:8002;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在项目的根目录上启动gunicorn时,一切顺利:
(sitepro) user@mybps:~/sitepro/site$ gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
[2017-11-01 16:09:37 +0000] [1920] [INFO] Starting gunicorn 19.7.1
[2017-11-01 16:09:37 +0000] [1920] [INFO] Listening at: http://79.137.39.12:8002 (1920)
[2017-11-01 16:09:37 +0000] [1920] [INFO] Using worker: sync
[2017-11-01 16:09:37 +0000] [1925] [INFO] Booting worker with pid: 1925
Run Code Online (Sandbox Code Playgroud)
我做了一个supervisorctrl重读和更新(工作).如果我做supervisorctl status sitepro
sitepro FATAL Exited too quickly (process log may have details)
Run Code Online (Sandbox Code Playgroud)
如果我访问我的网站,我就有了"欢迎使用Nginx"默认页面.
我已经尝试了许多用于部署django的教程:我迷失并尝试了很多东西.有人可以给我一个简单快速的教程来部署他用于他的propre needings的Django吗?
谢谢 !
问题是您缺少directory=...配置文件中的
[program:sitepro]
command = /home/user/sitepro/bin/gunicorn sitepro.wsgi:application --bind mywebsite.fr:8002
directory = /home/user/sitepro/site
user = user
autostart = true
autorestart = true
Run Code Online (Sandbox Code Playgroud)
否则gunicorn将不知道在哪里找到 sitepro.wsgi:application
要查看发生了什么,您应该记录主管的输出。
为此,请打开主管 .conf 文件,并添加以下行:
stdout_logfile={Path}
stderr_logfile={Path}
autostart=true
autorestart=true
startsecs=10
Run Code Online (Sandbox Code Playgroud)
可能的 {Path} 可能是 /home/{youruser}/sitepro.log
重启主管
supervisorctl restart sitepro
Run Code Online (Sandbox Code Playgroud)
重新启动后,转到日志并告诉我们您看到了什么。
| 归档时间: |
|
| 查看次数: |
12551 次 |
| 最近记录: |