uwsgi
- 安裝
pip install uwsgi -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
在conda環境下大概率安裝不成功,可以使用一下命令代替:
conda install -c conda-forge uwsgi
- django項目配置文件uwsgi.ini
# uwsgi.ini file
[uwsgi]
# the socket (use the full path to be safe
socket = /your/project/PATH/mysite.sock #單獨配置socket一般與nginx同時使用
#http = your machine's IP:8000 #與socket同時配置可以用uwsgi直接啓動http服務
# Django-related settings
chdir = /your/project/PATH # the base directory (full path)
module = yourprojectNAME.wsgi # Django's wsgi file
# process-related settings
master = true # master
processes = 3 # maximum number of worker processes
#output file settings
vacuum = true # clear environment on exit
pidfile =uwsgi0.pid # 存儲pid進程
stats =uwsgi.status # 存儲uwsgi狀態
daemonize =uwsgi.log #後臺運行,存儲log
#other settings
buffer-size = 65536
chmod-socket = 666 # ... with appropriate permissions - may be needed
- 啓動
uwsgi -i uwsgi.ini
- 停止
#查看進程號
cat uwsgi.pid
#停止進程
uwsgi --stop uwsgi.pid
kill pid
- 服務器開機自啓動
#編輯文件/etc/rc.local, 添加下面內容到這行代碼之前exit 0:
/usr/local/bin/uwsgi --ini /your/project/path/uwsgi.ini