nginx uwsgi 설정
설치
$ source activate py3.6
$ conda install -c anaconda icu
$ pip install uwsgi
$ uwsgi --version
//# libpcre.so.1: cannot open shared object file: No such file or directory
//# ,
$ find / -name "libpcre.so*" -type f
$ ln -s /usr/lib64/libpcre.so /usr/lib64/libpcre.so.1
//# ,
//#
$ cat test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return b"Hello world!
"
//# usgi
$ uwsgi --http :8001 --wsgi-file test.py
$ curl http://localhost:8001
nginx 는 http 요청 을 받 아 uwsgi 에 전달 하기 때문에 보통 uwsgi 를 먼저 시작 합 니 다.
uwsgi 설정, 동적 모드, nging 에 적용
$ cat /etc/uwsgi.ini
[uwsgi]
socket = 127.0.0.1:9090
uid = www
gid = www
master = true
vhost = true
no-site = true
workers = 10
reload-mercy = 10
vacuum = true
max-requests = 1000
buffer-size = 30000
pidfile = /var/run/uwsgi.pid
daemonize = /var/log/nginx/uwsgi.log
enable-threads = true
thunder-lock = true
다운로드 nginx
$ yum install nginx
$ vi /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
server_name _;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
uwsgi_param UWSGI_SCRIPT wsgi;
uwsgi_param UWSGI_CHDIR /usr/share/nginx/html/test;
client_max_body_size 35m;
}
}
//# python
$ mkdir /usr/share/nginx/html/test
//# uwsgi wsgi.py
$ cat /usr/share/nginx/html/test/wsgi.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return b"Hello world!
"
//# uwsgi
$ uwsgi --ini /etc/uwsgi.ini
//# nginx
$ service nginx start
//#
$ curl http://localhost:80
uwsgi 시작 스 크 립 트
$ vi /etc/init.d/uwsgi
#!/bin/bash
# uwsgi script
# it is v.0.0.1 version.
# chkconfig: - 89 19
# description: uwsgi script
# processname: uwsgi
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
### modify by user
export PYTHONHOME=/usr/local/anaconda3/envs/py3.6
uwsgi_config=/etc/uwsgi.ini
PIDFILE=`sed -n '/^pidfile/p' ${uwsgi_config} | awk -F "=" '{print $2}'|tr -d [:space:]`
uwsgi=$PYTHONHOME/bin/uwsgi
### modify end
# Source function library.
. /etc/rc.d/init.d/functions
# Start uwsgi daemons functions.
start() {
# check if runing
if [ -f $PIDFILE ];then
FILEPID=`cat $PIDFILE`
isRun=`ps aux|grep $FILEPID| grep -v grep`
if [ -n "$isRun" ];then
echo "uwsgi (pid $FILEPID) already running."
exit 0
else
rm -f $PIDFILE
fi
fi
daemon $uwsgi --ini ${uwsgi_config}
if [ -f $PIDFILE ];then
FILEPID=`cat $PIDFILE`
isRun=`ps aux|grep $FILEPID| grep -v grep`
if [ -n "$isRun" ];then
echo "uwsgi (pid $FILEPID) start sucess."
else
rm -f $PIDFILE
echo "uwsgi start failed."
fi
else
echo "uwsgi start failed."
fi
}
# Stop nginx daemons functions.
stop() {
if [ -f $PIDFILE ];then
echo "stop form the pidfile"
kill -2 `cat $PIDFILE`
rm -f $PIDFILE
echo "stop uwsgi done"
else
echo " uwsgi don't runing"
fi
}
# reload the process
reload() {
if [ -f $PIDFILE ];then
$uwsgi --reload $PIDFILE
echo " uwsgi reload success"
else
echo " uwsgi don't runing"
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
sleep 1
start
;;
*)
echo $"Usage: $prog {start|stop|restart|reload}"
exit 1
esac
exit $RETVAL
시스템 서비스 추가
chmod +x /etc/init.d/uwsgi
chkconfig --add uwsgi
service uwsgi restart
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.