五步教你实现使用Nginx+uWSGI+Django方法部署Django程序
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了五步教你实现使用Nginx+uWSGI+Django方法部署Django程序,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含25130字,纯文字阅读大概需要36分钟。
内容图文
![五步教你实现使用Nginx+uWSGI+Django方法部署Django程序](/upload/InfoBanner/zyjiaocheng/157/9a8a050a6cb444bea0e427cfa736a8f9.jpg)
NOTE:不使用nginx,只使用uwsgi+django也是可以实现WEB服务的。uwsgi也可以直接处理WEB请求。
第一步先解决uwsgi与django的桥接。解决在没有nginx的情况下,如何使用uwsgi+DJANGO来实现一个简单的Web服务器。
第二步解决uwsgi与Nginx的桥接。通过nginx与uwsgi的桥接,打通nginx与django的连通,从而比较完美的实现django的部署。
环境介绍
安装uwsgi
<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(187,96,213)">$ <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(0,112,32)">export <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(187,96,213)">LDFLAGS<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">=<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,112,160)">"-Xlinker --no-as-needed"<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(187,96,213)">$ pip install uwsgi
测试uwsgi
# test.py def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return "Hello World"
uwsgi --http :8001 --wsgi-file test.py
配置django
NOTE:
请保证你的django项目是正常使用的。可以使用
python manage.py runserver 0.0.0.0:8002
来测试一下你的django项目是否能正常跑起来。
注意: 编写文件时需要注意语句os.environ.setdefault。比如,如果你的项目为mysite,则你的语句应该是 <codeAndale Mono WT','Andale Mono','Lucida Console','Lucida Sans Typewriter','DejaVu Sans Mono','Bitstream Vera Sans Mono','Liberation Mono','Nimbus Mono L',Monaco,'Courier New',Courier,monospace!important; color:rgb(0,0,0); font-size:0.98em">os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
1 2 3 4 5 6 7 8 9 10 11 12 13 14<tdPalatino Linotype',Times,'Times New Roman',serif!important; vertical-align:top">
<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(96,160,176); font-style:italic">#!/usr/bin/env python<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(96,160,176); font-style:italic"># coding: utf-8<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(0,112,32); font-weight:bold">import<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">os<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(0,112,32); font-weight:bold">import<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">sys<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(96,160,176); font-style:italic"># 将系统的编码设置为UTF8<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(0,112,32)">reload<spanPalatino Linotype',Times,'Times New Roman',serif!important">(<spanPalatino Linotype',Times,'Times New Roman',serif!important">sys<spanPalatino Linotype',Times,'Times New Roman',serif!important">)<spanPalatino Linotype',Times,'Times New Roman',serif!important">sys<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">setdefaultencoding<spanPalatino Linotype',Times,'Times New Roman',serif!important">(<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,112,160)">'utf8'<spanPalatino Linotype',Times,'Times New Roman',serif!important">)<spanPalatino Linotype',Times,'Times New Roman',serif!important">os<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">environ<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">setdefault<spanPalatino Linotype',Times,'Times New Roman',serif!important">(<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,112,160)">"DJANGO_SETTINGS_MODULE"<spanPalatino Linotype',Times,'Times New Roman',serif!important">,<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,112,160)">"mysite.settings"<spanPalatino Linotype',Times,'Times New Roman',serif!important">)<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(0,112,32); font-weight:bold">from<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">django.core.handlers.wsgi<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(0,112,32); font-weight:bold">import<spanPalatino Linotype',Times,'Times New Roman',serif!important">WSGIHandler<spanPalatino Linotype',Times,'Times New Roman',serif!important">application<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">=<spanPalatino Linotype',Times,'Times New Roman',serif!important">WSGIHandler<spanPalatino Linotype',Times,'Times New Roman',serif!important">()
连接django和uwsgi,实现简单的Web服务器。
uwsgi --http :8000 --chdir /home/work/src/sites/testdjango1/testdjango/mysite --module django_wsgi
最后:
参考、解释及其它
wsgi: WSGI是一种Web服务器网关接口。它是一个Web服务器(如nginx)与应用服务器(如uWSGI服务器)通信的一种规范。
关于WSGI协议看这里:WSGI
uWSGI: http://uwsgi-docs.readthedocs.org/en/latest/index.html uWSGI是一个Web服务器,它实现了WSGI协议、uwsgi、http等协议。 Nginx中HttpUwsgiModule的作用是与uWSGI服务器进行交换。
uwsgi: uwsgi同WSGI一样是一种通信协议,而uWSGI是实现了uwsgi和WSGI两种协议的Web服务器。
uwsgi协议是一个uWSGI服务器自有的协议,它用于定义传输信息的类型(type of information),每一个uwsgi packet前4byte为传输信息类型描述,它与WSGI相比是两样东西。
关于uwsgi协议看这里:The uwsgi protocol
有了uWSGI为什么还需要nginx?
nginx具备优秀的静态内容处理能力,然后将动态内容转发给uWSGI服务器,这样可以达到很好的客户端响应。
参考文献:http://heipark.iteye.com/blog/1750970
<pPalatino Linotype',Times,'Times New Roman',serif!important">当然,单单只有uWSGI是不够的,在实际的部署环境中,Nginx是必不可少的工具。
环境介绍
配置uWSGI
<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"><spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"> :8077<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"> <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">/home/work/src/sites/testdjango1/testdjango/mysite<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"> <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">django_wsgi<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"> <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">4<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"> <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(96,160,176); font-style:italic"><spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">uwsgi.log<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold"> <spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">
配置Nginx
<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">server<spanPalatino Linotype',Times,'Times New Roman',serif!important">{<spanPalatino Linotype',Times,'Times New Roman',serif!important">listen<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">80<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">server_name<spanPalatino Linotype',Times,'Times New Roman',serif!important">www<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">you<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">com<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">access_log<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">home<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">work<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">var<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">test<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">logs<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">access<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">log<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">error_log<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">home<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">work<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">var<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">test<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">logs<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">error<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">log<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">#charse<spanPalatino Linotype',Times,'Times New Roman',serif!important">t<spanPalatino Linotype',Times,'Times New Roman',serif!important">koi8<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">-<spanPalatino Linotype',Times,'Times New Roman',serif!important">r<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">#access<spanPalatino Linotype',Times,'Times New Roman',serif!important">_log<spanPalatino Linotype',Times,'Times New Roman',serif!important">logs<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">host<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">access<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">log<spanPalatino Linotype',Times,'Times New Roman',serif!important">main<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">location<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">{<spanPalatino Linotype',Times,'Times New Roman',serif!important">include<spanPalatino Linotype',Times,'Times New Roman',serif!important">uwsgi_params<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">uwsgi_pass<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">127<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">0<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">0<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">1<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">:<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(64,160,112)">8077<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">}<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,126)">#error_page<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">404<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">404<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">.html<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">#<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">redirect<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">server<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">error<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">pages<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">to<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">the<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">static<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">page<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">50x<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">.html<spanPalatino Linotype',Times,'Times New Roman',serif!important">#<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">error_page<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">500<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">502<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">503<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">504<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">50x<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">.html<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">;<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">location<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">=<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">50x<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(14,132,181); font-weight:bold">.html<spanPalatino Linotype',Times,'Times New Roman',serif!important">{<spanPalatino Linotype',Times,'Times New Roman',serif!important">root<spanPalatino Linotype',Times,'Times New Roman',serif!important">html<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">}<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">location<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">static<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">{<spanPalatino Linotype',Times,'Times New Roman',serif!important">alias<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">home<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">work<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">src<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">sites<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">testdjango1<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">testdjango<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">collectedstatic<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">index<spanPalatino Linotype',Times,'Times New Roman',serif!important">index<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">html<spanPalatino Linotype',Times,'Times New Roman',serif!important">index<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">.<spanPalatino Linotype',Times,'Times New Roman',serif!important">htm<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">}<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">location<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(6,40,115); font-weight:bold">media<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">{<spanPalatino Linotype',Times,'Times New Roman',serif!important">alias<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">home<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">work<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">src<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">sites<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">testdjango1<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">testdjango<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">public<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">media<spanPalatino Linotype',Times,'Times New Roman',serif!important; color:rgb(102,102,102)">/<spanPalatino Linotype',Times,'Times New Roman',serif!important">;<spanPalatino Linotype',Times,'Times New Roman',serif!important">}<spanPalatino Linotype',Times,'Times New Roman',serif!important">}
Nginx+uWSGI+Django的实现方式
重启Nginx服务器,以使Nginx的配置生效。
nginx -s reload
重启后检查Nginx日志是否有异常。
启动uWSGI服务器
cd /home/work/src/sites/testdjango1/testdjango/mysite uwsgi -x djangochina_socket.xml
检查日志 uwsgi.log 是否有异常发现。
访问服务
基于上面的假设你的域名是www.you.com
因此,我们访问 www.you.com,如果发现程序与 单独使用Django启动的程序一模一样时,就说明成功啦!
关闭服务的方法
将uWSGi进程杀死即可。
一些建议
uWSG配置文件的进程数,可以根据实际情况分配。不要开得太大,否则机器可能会内存耗用太高。一般来说,对于一个小社区来说,4个进程已经足够了。
一般情况下,可以编写一下 stop.sh 脚本 来关闭uWSGI。
以上就介绍了五步教你实现使用Nginx+uWSGI+Django方法部署Django程序,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
内容总结
以上是互联网集市为您收集整理的五步教你实现使用Nginx+uWSGI+Django方法部署Django程序全部内容,希望文章能够帮你解决五步教你实现使用Nginx+uWSGI+Django方法部署Django程序所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。