1、安裝uwsgi
# pip install uwsgi
2、建立uwsgi.ini,當然此處隻看字尾,檔案名可以随便起
ite_uwsgi.ini file
[uwsgi]
# Django-related settings
#socket = :8888,如果django設計的是API,則用http前端可以請求;socket使用于純後端處理資料流
http = :8888
post-buffering = 8192
post-buffering-bufsize = 65536
# thunder-lock
thunder-lock = true
# reload rss
reload-on-rss = 64
# the base directory (full path),切換到manage.py檔案所在目錄
chdir= /home/ubuntu/project/project/
# Django s wsgi file,project.wsgi這個名字是django項目的名字,字尾為wsgi
module = project.wsgi
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 4
# ... with appropriate permissions - may be needed
# chmod-socket = 664
#thread numbers startched in each worker process
#threads = 10
#monitor uwsgi status 通過該端口可以監控 uwsgi 的負載情況
stats = 0.0.0.0:9192
workers = 4
# 并發處理程序數
listen = 4
# 并發的socket 連接配接數。預設為100。優化需要根據系統配置
# clear environment on exit
vacuum = true
# 背景運作,并輸出日志
daemonize = /home/ubuntu/project/project/uwsgi.log
# 如果想加載靜态檔案,則配置靜态檔案所在目錄
static-map=/static=/home/ubuntu/project/project/static
3、記得将django中settings.py檔案中的以下進行修改,不然影響性能;DEBUG等于True隻是為了滿足開發人員自測用的,性能很差
DEBUG = True 改成 DEBUG = False
4、開啟uwsgi
# uwsgi --ini uwsgi.ini
5、殺掉所有uwsgi程序
# pkill -f -9 uwsgi