标签:
学这个搞了我2天。最好的东西学会了怎排除问题。
直接贴代码,我同时部署2个项目,一个直接返回‘ hello‘,另一个空。
hello 项目:
/root/27env/hello/uwsgi.ini:
##################################
[uwsgi]
vhost = false
plugins = python
socket = 127.0.0.1:8080
master = true
enable-threads = true
workers = 1
wsgi-file = /root/27env/hello/hello/wsgi.py
chdir = /root/27env/hello
########################
/etc/nginx/sites-available/hello.conf
###########################
upstream django {
server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8080; # for a web port socket (we‘ll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
#server_name http://120.25.146.222:8000/; # substitute your machine‘s IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
# location /media {
# alias /path/to/your/mysite/media; # your Django project‘s media files - amend as required
# }
# location /static {
# alias /path/to/your/mysite/static; # your Django project‘s static files - amend as required
# }
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include uwsgi_params; # the uwsgi_params file you installed
}
}
###################################
需要执行sudo
ln
-s
/etc/nginx/sites-available/zqxt
.conf
/etc/nginx/sites-enabled/zqxt
.conf
启动nginx :
service nginx start
启动uwsgi :
uwsgi: --ini uwsgi.ini
使用supervisord管理:
/etc/supervisord.conf:
文件末端添加:
[program:hello]
command=/root/.pyenv/shims/uwsgi --ini /root/27env/hello/uwsgi.ini
directory=/root/27env/hello
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
[program:wx]
command=/root/.pyenv/shims/uwsgi --ini /root/27env/wx/weixin_project/weixin_project/uwsgi.ini
directory=/root/27env/wx/weixin_project
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
执行:supervisord -c /etc/supervisord.conf
操控: supervisorctl
...
weixin_project:
uwsgi:
[uwsgi]
vhost = false
plugins = python
socket = 127.0.0.1:8001
master = true
enable-threads = true
workers = 4
wsgi-file = /root/27env/wx/weixin_project/weixin_project/wsgi.py
chdir = /root/27env/wx/weixin_project
nginx配置:
server{
listen 8002;
charset utf-8;
client_max_body_size 75M;
location /{
uwsgi_pass 127.0.0.1:8001;
include uwsgi_params;
uwsgi_connect_timeout 30;
}
}
。外网访问地址:http://120.25.146.222:8000/
http://www.jianshu.com/p/e6ff4a28ab5a
django1.8+uwsgi+nginx+supervisord部署项目笔记
标签:
原文地址:http://my.oschina.net/u/2367514/blog/515974