Nginx+UWSGI+Django配置全过程

时间:2023-03-08 16:27:48

重度参阅

原理+实战
http://zhou123.blog.51cto.com/4355617/1688434

原理
http://www.cnblogs.com/fnng/p/5268633.html

轻微参阅:
http://www.ziqiangxuetang.com/django/django-nginx-deploy.html
https://github.com/binbin91/oms/blob/master/install.txt

http://binbin158.blog.51cto.com/2659767/1569298

OMS程序:

https://github.com/binbin91/oms

遇到错误:

修改myapp_uwsgi.ini 的运行用户为root

[root@moban myapp]# pwd
/root/d/myapp
[root@moban myapp]# tree .
.
├── manage.py
├── myapp
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
└── myapp_uwsgi.ini

[root@moban myapp]# pwd
  /root/d/myapp

[root@moban myapp]# cat myapp_uwsgi.ini

[uwsgi]
uid = root
gid = root
chdir = /root/d/myapp
module = myapp.wsgi
master = true
processes =
listen =
socket = /tmp/myapp.sock
pidfile = /var/run/uwsgi.pid
vacuum = true
enable-threads = true
buffer-size =
reload-mercy =
max-requests =
limit-as =
harakiri =
daemonize = /var/log/myapp_uwsgi.log

2,修改socket目录为 /tmp  (免去新建test并授权的过程)

3,uwsgi --http :8000 --wsgi-file myapp/wsgi执行错误

uwsgi --http :8000 --wsgi-file myapp/wsgi.py  执行正确

4,看nginx error日志  看下为啥访问不了呢(改了nginx.conf没reload nginx导致)

tail /application/nginx/logs/error.log

5,uwsgi --ini myapp_uwsgi.ini   #仅这个命令启动即可