[root@linuxidc ~]# chkconfig --list uwsgid uwsgid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
启动uwsgid
[root@linuxidc ~]# service uwsgid start Starting uwsgi: [uWSGI] getting INI configuration from /usr/local/webtest/uwsgi.ini
验证下监听端口(注:这里我们使用127.0.0.1 作监听,是为了后期在使用时,对外只有nginx可以访问web应用):
[root@linuxidc ~]# netstat -aultnp | grep :8000 tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 8945/uwsgi
9) 安装Nginx配置代理
先下载安装6.6的epel源
[root@linuxidc ~]# wget https://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm [root@linuxidc ~]# rpm -ivh epel-release-6-8.noarch.rpm
安装nginx
[root@linuxidc ~]# yum install nginx -y
安装完成后,修改nginx默认配置文件default.conf,修改之前可以先备份下源文件噢。完整内容如下:
[root@linuxidc ~]# cat /etc/nginx/conf.d/default.conf server { listen 80; server_name 192.168.30.58; location / { include uwsgi_params; uwsgi_pass 127.0.0.1:8000; uwsgi_param UWSGI_SCRIPT wsgi; uwsgi_param UWSGI_CHDIR /usr/local/webtest; index index.html index.htm; client_max_body_size 35m; } }
以上内容代理了uwsgi的端口,客户端通过访问nginx的80端口,然后nginx在将请求转发到后台flask应用的8000端口上。
启动nginx
[root@linuxidc ~]# service nginx start Starting nginx: [ OK ]
在浏览器内测试访问一下nginx:
更多参考
Nginx+uWSGI+Supervisor在Ubuntu上部署Flask应用
Ubuntu Server 12.04 安装Nginx+uWSGI+Django环境
Nginx+uWSGI+Django+Python 应用架构部署
Ubuntu Server 14.04.2 LTS 配置 Nginx + Uwsgi + Django