一、安装uwsgi、flup、django
wget http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gzpython
二、项目建立和配置
2.一、建立项目nginx
cd /root/codes/
django-admin.py startproject myproject
2.二、建立/root/codes/uwsgi.xmldjango
<uwsgi> <socket>0.0.0.0:8001</socket> <pythonpath>/root/codes/myproject</pythonpath> <module>django_wsgi</module> <profiler>true</profiler> <memory-report>true</memory-report> <enable-threads>true</enable-threads> <logdate>true</logdate> <limit-as>6048</limit-as> </uwsgi>
2.三、建立/root/codes/django_wsgi 浏览器
import os import django.core.handlers.wsgi os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' #"项目名.settings" application = django.core.handlers.wsgi.WSGIHandler()
2.五、nginx 配置bash
能够直接修改/etc/nginx/nginx.conf或者在conf.d中添加一个conf后缀的文件,配置以下:服务器
location ~ /zhaoshihui { #include uwsgi_params; #uwsgi_pass 127.0.0.1:8001; fastcgi_pass 127.0.0.1:8001; root /root/codes/zhaoshihui/; }
2.六、建立启动和重启脚本/root/codes/run.shapp
#!/bin/bash ps -efa | grep "port=8001" | grep -v "grep port=8001" | awk '$3==1 {print "kill -9 " $2}' | sh python manage.py runfcgi host=127.0.0.1 port=8001 ps -efa | grep "port=8001" | grep -v "grep port=8001"
三、启动应用
sh /root/codes/run.shsocket
四、在浏览器中访问
http://服务器ip/myprojectui