安装
/usr/local/anaconda3/bin/pip install gunicorn
配置:
-
import multiprocessing
-
bind = "127.0.0.1:8000"
-
workers = multiprocessing.cpu_count() * 2 + 1
-
basedir = "/root/python/mysite"
-
errorlog = basedir+"/gunicorn.error.log"
-
#loglevel = "debug"
-
proc_name = "mysite"
-
reload = True
-
daemon = True
启动脚本
-
#!/bin/bash
-
-
GUNICORN=/usr/local/anaconda3/bin/gunicorn
-
ROOT=/root/python/mysite
-
PID=/tmp/gunicorn.pid
-
-
APP=mysite.wsgi
-
-
case "$1" in
-
start)
-
cd $ROOT
-
exec $GUNICORN -c $ROOT/gunicorn/gunicorn.py -D --pid=$PID --error-logfile $ROOT/gunicorn/error.log $APP
-
echo "gunicorn is start"
-
;;
-
stop)
-
kill `cat $PID`
-
echo "gunicorn is stop"
-
;;
-
*)
-
echo "$0 (stop|start)"
-
;;
-
esac
nginx配置
-
server {
-
listen 80;
-
server_name _;
-
-
access_log /var/log/nginx/mysite_access.log;
-
error_log /var/log/nginx/mysite_error.log;
-
include /etc/nginx/uwsgi_params;
-
-
location / {
-
proxy_pass
-
}
-
-
location ^~ /static {
-
access_log off;
-
alias /root/python/mysite/static;
-
}
-
-
}
阅读(1362) | 评论(0) | 转发(0) |