走了点弯路,配置文档直接看官网文档比较好。
https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/uwsgi/
环境:
OS:centos5.6 x64
python:2.7.3
django:1.5
uwsgi: 1.9.5
nginx:1.3
一 下载uwsgi
#wget http://projects.unbit.it/downloads/uwsgi-1.9.5.tar.gz
#tar zxvf uwsgi-1.9.5.tar.gz
#cd uwsgi-1.9.5
#python setup.py install
#cp contrib/centos_init_script /etc/init.d/uwsgi
二 编辑nginx配置文件
编辑nginx.conf加入下面一行
#vi django.conf
server
{
listen 80;
server_name func.mysite.com;
location / {
root /www/FUNCMG/FUNCMG;
default_type text/html;
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
}
location ~/static {
root /www/FUNCMG/;
}
}
三 编辑uwsgi配置文件
#vim /usr/local/nginx/conf/uwsgi.ini(也可以放在项目根目录)
[uwsgi]
chdir = /www/FUNCMG
module = FUNCMG.wsgi
socket = 127.0.0.1:8000
porcesses = 2
pidfile = /var/run/django_uwsgi.pid
master = True
workers = 4
daemonize = /www/logs/django_uwsgi.log
四 运行
修改启动脚本/etc/init.d/uwsgi
PATH=/usr/local/python/bin:$PATH
DAEMON_OPTS="--ini /usr/local/nginx/conf/uwsgi.ini"
启动
/etc/init.d/uwsgi start
启动nginx
/etc/init.d/nginx start
五 最终效果
提供一键安装版本,适用于rhel(centos)5 x64系统
https://github.com/ahwind/one-key-django/