1. 安装uwsgi依赖
yum groupinstall "Development Tools"
yum install python
yum install python-devel
yum install -y libxml2-devel
2. 编译安装uwsgi
wget http://projects.unbit.it/downloads/uwsgi.it-latest.tar.gz
tar xf uwsgi.it-latest.tar.gz
cd uwsgi-2.0.14/
python uwsgiconfig.py --build
cp uwsgi /usr/sbin/
3. nginx配置:
# cat /usr/local/gacp/nginx/conf/vhosts.d/app.balance.conf
server {
listen 58080;
server_name 58080;
access_log /data/logs/nginx/access/app.balance.access.log main;
error_log /data/logs/nginx/error/app.balance.error.log;
root /data/www;
location /
{
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
}
}
创建网站根目录:
mkdir /data/www
创建应用配置文件:
# cat app.xml
<uwsgi>
<socket>:9090</socket>
<chdir>/data/www/app</chdir>
<wsgi-file>test.py</wsgi-file>
<module>app</module>
<processes>4</processes>
</uwsgi>
创建应用目录和入口文件:
mkdir /data/www/app
cd /data/www/app
cat test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World"
启动uwsgi进程:
nohup uwsgi -x app.xml &
测试应用是否正常:
浏览器访问 ip:58080