CentOS 7環境部署(5)——uwsgi


一、環境介紹
操作系統:centos7.6(64位)
uwsgi的版本:uwsgi2.0.17.1
使用工具:Xshell
二、安裝uwsgi
1.安裝依賴包

A. 安裝libxml*:yum install libxml*

B. 安裝python-devel:yum install python-devel -y

C. 安裝編譯工具:yum install -y gcc* pcre-devel openssl-devel

D. yum install python3-devel

2.安裝uwsgi 2.0.17.1

A. yum -y install uwsgi uwsgi-devel uwsgi-plugin-python

B. 建立軟鏈接:ln -s /usr/local/python3Dir/bin/uwsgi /usr/bin/uwsgi
3.測試uwsgi是否安裝成功
A. 進入目錄:cd /test_uwsgi
B. 新建test.py測試文件:

def application(env, start_response):
	start_response('200 OK', [('Content-Type','text/html')])
        return [b"Hello World"]

C. 新建uwsgi.ini配置文件:
[uwsgi]
socket = ip地址:8000
wsgi-file = test.py
#plugins = python
chdir =/test_uwsgi
processes = 2
threads = 2
stats = 127.0.0.1:9191
D. 進入default.conf 目錄:cd /etc/nginx/conf.d
E. 備份default.conf 文件:cp default.conf default.conf.bak
F. 修改default.conf文件內容:
其中:server_name localhost; #有域名填寫域名,沒域名寫localhost
uwsgi_pass ip地址:8000; #端口和uwsgi里配置的一樣
G. 重新啟動nginx :nginx -s reload
H. 啟動uwsgi:uwsgi --ini /qcj_test/test_uwsgi/uwsgi.ini
I. 瀏覽器輸入ip地址,出現Hello World,uwsgi啟動成功。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM