uWSGI+Nginx安装、配置
生活随笔
收集整理的這篇文章主要介紹了
uWSGI+Nginx安装、配置
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、關(guān)閉SELINUX:
[root@PYTHON27 /]# vim /etc/selinux/config 將SELINUX=enforcing修改為SELINUX=disabled2、關(guān)閉防火墻:
[root@PYTHON27 /]# service iptables stop [root@PYTHON27 /]# chkconfig iptables off3、安裝EPEL源:
[root@PYTHON27 /]# yum -y install epel-release [root@PYTHON27 /]# yum clean all [root@PYTHON27 /]# yum makecache4、安裝系統(tǒng)工具:
[root@PYTHON27 /]# yum -y install vim wget telnet5、安裝編譯支持包:
[root@PYTHON27 /]# yum -y install gcc gcc-c++ automake autoconf6、安裝Nginx支持包:
[root@PYTHON27 /]# yum -y install zlib zlib-devel pcre pcre-devel openssl openssl-devel7、安裝uwsgi及組件:
[root@PYTHON27 /]# yum -y install uwsgi uwsgi-devel uwsgi-plugin-python8、查看uwsgi版本:
[root@PYTHON27 /]# uwsgi --version 2.0.149、啟動(dòng)uwsgi項(xiàng)目:
[root@PYTHON27 /]# uwsgi --ini /usr/local/src/python-test/python-test.ini10、解壓nginx安裝包:
[root@PYTHON27 /]# tar -xzvf /usr/local/src/nginx-1.10.1.tar.gz -C /usr/local/src/11、編譯、安裝:
[root@PYTHON27 /]# cd /usr/local/src/nginx-1.10.1 [root@PYTHON27 nginx-1.10.1]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module [root@PYTHON27 nginx-1.10.1]# make -j 2 [root@PYTHON27 nginx-1.10.1]# make install12、修改Nginx配置文件:
[root@PYTHON27 /]# vim /usr/local/nginx/conf/nginx.conf 將下邊內(nèi)容:location / {root html;index index.html index.htm;}替換為:location / {include uwsgi_params;uwsgi_read_timeout 3600;uwsgi_pass 127.0.0.1:9090;}13、啟動(dòng)nginx服務(wù):
[root@PYTHON27 /]# /usr/local/nginx/sbin/nginx -t [root@PYTHON27 /]# /usr/local/nginx/sbin/nginx14、測(cè)試:
[root@PYTHON27 /]# curl http://192.168.75.150/ Hello World?
源碼:
python-test.py:
def application(env, start_response):start_response('200 OK', [('Content-Type','text/html')])return ["Hello World"]python-test.ini:
[uwsgi] socket = 127.0.0.1:9090 wsgi-file = /usr/local/src/python-test/python-test.py plugins = python chdir = /usr/local/src/python-test processes = 2 threads = 2 post-buffering = 8192 buffer-size = 65535 socket-timeout = 10 stats = 127.0.0.1:9191 # callable = python-test uid = uwsgi gid = uwsgi master = true protocol = uwsgi buffer-size = 8192 pidfile = /var/run/uwsgi9090.pid # daemonize = /var/log/uwsgi9090.log注釋: socket = 127.0.0.1:9090 ##啟動(dòng)端口9090的服務(wù),需用nginx代理,可以對(duì)外提供服務(wù)。
http-socket = 127.0.0.1:9090 ##啟動(dòng)端口9090的服務(wù),可以直接對(duì)外提供服務(wù)。
?
python-test.py:通過(guò)WEB頁(yè)面執(zhí)行服務(wù)器上的腳本:
import osdef application(env, start_response):os.chdir('/usr/local/src/python-test')retcode = os.system('sh dir.sh')if retcode == 0:ret = 'success!'else:ret = 'failure!'start_response('200 OK', [('Content-Type','text/html')])return [ret]?
[END]
轉(zhuǎn)載于:https://www.cnblogs.com/configure/p/6401695.html
總結(jié)
以上是生活随笔為你收集整理的uWSGI+Nginx安装、配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: windows7安装django并创建第
- 下一篇: Service Work