之前正式环境是跑的uwsgi,这次升级之后,
以前的nginx和uwsgi的配置都过时而不可用了。
我们需要的是通过二级目录访问,而不能用根目录,
因为根目录用于整体工具的网页导航。
这次重新搜索了文档,让相关的多应用再跑起来了。
uwsgi版本:
2.0.15
====================之前的nginx和uwsgi配置=====python2.7 django1.8==============
upstream xxx_host {
server ip:host;
}
server {
listen 80;
server_name localhost;
location /xxx/ {
include uwsgi_params;
uwsgi_pass xxx_host;
uwsgi_param SCRIPT_NAME /xxx;
uwsgi_modifier1 30; #此行加上面,进行丑陋patch
index index.html index.htm;
client_max_body_size 1000m;
client_body_timeout 5m;
proxy_connect_timeout 5m;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
}
location ^~ /xxx/static {
alias /xx/xx/static;
}
}
[uwsgi]
socket = ip:9090
chdir = /xxx/xx/xx/xx
module = settings.wsgi #(定位wsgi目录及文件,结合上面的chdir)
master = true
vhost = true
no-stie = true
workers = 4
reload-mercy = 10
vacuum = true
max-requests = 1000
limit-as = 512
buffer-sizi = 30000
pidfile = /var/log/xxx/uwsgi9090.pid
daemonize = /var/log/xxx/uwsgi9090.log
listen=1024
====================现在的nginx和uwsgi配置=====python3.6 django2.0==============
upstream xxx_host {
server ip:9090;
}
server {
listen 80;
server_name localhost;
location /xxx/ {
include uwsgi_params;
uwsgi_pass xxx_host;
client_max_body_size 1000m;
client_body_timeout 5m;
proxy_connect_timeout 5m;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
}
location ^~ /xxx/static {
alias /xx/xxxx/xxstatic;
}
}
[uwsgi]
socket = ip:9090
mount = /xxx=/xxx/xx/xxxx/settings/wsgi.py
manage-script-name = true # 此行加上行定位,比前面优雅
master = true
vhost = true
no-stie = true
workers = 4
reload-mercy = 10
vacuum = true
max-requests = 1000
limit-as = 512
buffer-sizi = 30000
pidfile = /var/log/xxx/uwsgi9090.pid
daemonize = /var/logxxx/uwsgi9090.log
listen=1024
再来一个uwsgi系统服务启停命令的脚本:
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for uwsgi webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f uwsgi defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add uwsgi'
### BEGIN INIT INFO
# Provides: uwsgi
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the uwsgi web server
# Description: starts uwsgi using start-stop-daemon
### END INIT INFO
# Author: licess
# website: http://lnmp.org
PATH=/usr/local/venv_py3/bin
DESC="uwsgi daemon"
NAME=uwsgi9090
DAEMON=/root/xxx/venv_py3/bin/uwsgi
CONFIGFILE=/root/xxx/xxx/$NAME.ini
PIDFILE=/var/log/prism/$NAME.pid
SCRIPTNAME=/root/xxx/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON $CONFIGFILE || echo -n "uwsgi already running"
}
do_stop() {
$DAEMON --stop $PIDFILE || echo -n "uwsgi not running"
rm -f $PIDFILE
echo "$DAEMON STOPED."
}
do_reload() {
$DAEMON --reload $PIDFILE || echo -n "uwsgi can't reload"
}
do_status() {
ps aux|grep $DAEMON
}
case "$1" in
status)
echo -en "Status $NAME: \n"
do_status
;;
start)
echo -en "Starting $NAME: \n"
do_start
;;
stop)
echo -en "Stopping $NAME: \n"
do_stop
;;
reload|graceful)
echo -en "Reloading $NAME: \n"
do_reload
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload}" >&2
exit 3
;;
esac
exit 0
uwsgi9090