- 参考文档:https://www.cnblogs.com/logicalsky/p/5685603.html
- 报错前提:项目是用django1.11版本写的服务器环境里django是1.9版本。
- 项目能正常runserver。
- uwsgi代码copy了前面的项目:
[uwsgi]
# Django-related settings
socket = 127.0.0.1:8002
# the base directory (full path)
chdir = /root/Project/XMJonline
# Django s wsgi file
module = XMJonline.wsgi
daemonize = /var/log/django.log
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 4
# ... with appropriate permissions - may be needed
chmod-socket = 664
# clear environment on exit
vacuum = true
buffer-size=32768
- nginx代码copy了前面的项目,监听83端口:
server { listen 83; server_name 120.79.192.204; # 域名 access_log /var/log/nginx/access_jamin.log main; error_log /var/log/nginx/error_jamin.log; location / { root html; include uwsgi_params; uwsgi_pass 127.0.0.1:8003; uwsgi_read_timeout 2; } location /static { expires 30d; autoindex on; add_header Cache-Control private; alias /root/Project/JamBlog/static; } }
- 启动项目发现83端口报错
- 查看nginx报错日志,nginx无报错。
- 继续查看uwsgi报错日志:
“--no python application found, check your startup logs for errors--”
- 确认代码及路径跟之前成功部署的项目一样(仅django版本不一样,前面的都是用1.9的库下写的)
- 经各种查询排查后,修改了uwsgi以下代码,项目便正常了
[uwsgi]# Django-related settings socket = 127.0.0.1:8003virtualenv = /root/Env/Env_py36_XMJonline# the base directory (full path) chdir = /root/Project/JamBlogpythonpath=/root/Project/JamBlog# Django s wsgi file module = JamBlog.wsgidaemonize = /var/log/django.log# process-related settings # master master = true# maximum number of worker processes processes = 4# ... with appropriate permissions - may be needed chmod-socket = 664# clear environment on exit vacuum = truebuffer-size=32768
改成了wsgi文件的根目录