一、安裝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