uWSGI+Nginx安装、配置
来源:互联网 发布:软件专业毕业论文题目 编辑:程序博客网 时间:2024/06/05 08:24
1、关闭SELINUX:
1
[root@PYTHON27 /]
# vim /etc/selinux/config
1
将SELINUX=enforcing修改为SELINUX=disabled
2、关闭防火墙:
1
2
[root@PYTHON27 /]
# service iptables stop
[root@PYTHON27 /]
# chkconfig iptables off
3、安装EPEL源:
1
2
3
[root@PYTHON27 /]
# yum -y install epel-release
[root@PYTHON27 /]
# yum clean all
[root@PYTHON27 /]
# yum makecache
4、安装系统工具:
1
[root@PYTHON27 /]
# yum -y install vim wget telnet
5、安装编译支持包:
1
[root@PYTHON27 /]
# yum -y install gcc gcc-c++ automake autoconf
6、安装Nginx支持包:
1
[root@PYTHON27 /]
# yum -y install zlib zlib-devel pcre pcre-devel openssl openssl-devel
7、安装uwsgi及组件:
1
[root@PYTHON27 /]
# yum -y install python-devel uwsgi uwsgi-devel uwsgi-plugin-python
8、查看uwsgi版本:
1
2
[root@PYTHON27 /]
# uwsgi --version
2.0.14
9、启动uwsgi项目:
1
[root@PYTHON27 /]
# uwsgi --ini /usr/local/src/python-test/python-test.ini
10、解压nginx安装包:
1
[root@PYTHON27 /]
# tar -xzvf /usr/local/src/nginx-1.10.1.tar.gz -C /usr/local/src/
11、编译、安装:
1
2
3
4
[root@PYTHON27 /]
# cd /usr/local/src/nginx-1.10.1
[root@PYTHON27 nginx-1.10.1]
# ./configure --prefix=/usr/local/nginx --with-http_ssl_module
[root@PYTHON27 nginx-1.10.1]
# make -j 2
[root@PYTHON27 nginx-1.10.1]
# make install
12、修改Nginx配置文件:
1
[root@PYTHON27 /]
# vim /usr/local/nginx/conf/nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
将下边内容:
location / {
root html;
index index.html index.htm;
}
替换为:
location / {
include uwsgi_params;
uwsgi_read_timeout 3600;
uwsgi_pass 127.0.0.1:9090;
}
13、启动nginx服务:
1
2
[root@PYTHON27 /]
# /usr/local/nginx/sbin/nginx -t
[root@PYTHON27 /]
# /usr/local/nginx/sbin/nginx
14、测试:
1
2
[root@PYTHON27 /]
# curl http://192.168.75.150/
Hello World
源码:
python-test.py:
1
2
3
def application(
env
, start_response):
start_response(
'200 OK'
, [(
'Content-Type'
,
'text/html'
)])
return
[
"Hello World"
]
python-test.ini:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[uwsgi]
socket = 127.0.0.1:9090
wsgi-
file
=
/usr/local/src/python-test/python-test
.py
plugins = python
chdir =
/usr/local/src/python-test
processes = 2
threads = 2
post-buffering = 8192
buffer-size = 65535
socket-timeout = 10
stats = 127.0.0.1:9191
# callable = python-test
uid = uwsgi
gid = uwsgi
master =
true
protocol = uwsgi
buffer-size = 8192
pidfile =
/var/run/uwsgi9090
.pid
# daemonize = /var/log/uwsgi9090.log
注释: socket = 127.0.0.1:9090 ##启动端口9090的服务,需用nginx代理,可以对外提供服务。
http-socket = 127.0.0.1:9090 ##启动端口9090的服务,可以直接对外提供服务。
python-test.py:通过WEB页面执行服务器上的脚本:
1
2
3
4
5
6
7
8
9
10
11
import
os
def application(
env
, start_response):
os.chdir(
'/usr/local/src/python-test'
)
retcode = os.system(
'sh dir.sh'
)
if
retcode == 0:
ret =
'success!'
else
:
ret =
'failure!'
start_response(
'200 OK'
, [(
'Content-Type'
,
'text/html'
)])
return
[ret]
[END]
阅读全文
0 0
- uWSGI+Nginx安装、配置
- nginx和uwsgi安装配置
- Django Nginx+uwsgi 安装配置
- Nginx+uWSGI安装与配置
- Django Nginx+uwsgi 安装配置
- Django Nginx+uwsgi 安装配置
- Django Nginx+uwsgi 安装配置
- uwsgi安装及配置搭档nginx
- Nginx+uwsgi+django+RabbitMQ+celery安装配置
- Nginx + uwsgi + django 配置
- nginx + uwsgi简单配置
- Nginx + uWSGI + Django 配置
- nginx + django + uwsgi 配置
- django+uWSGI+Nginx配置
- django + uwsgi + nginx 配置
- nginx和uwsgi配置
- nginx配置uwsgi
- uWSGI+nginx+静态配置
- java发送邮件附件.网页.文本类型的实现(Content的内容设计)
- H5游戏开发:推金币
- ?迭代时改变集合里的元素
- 跟我学习dubbo-Dubbo管理控制台的安装(3)
- vs2013+opencv2.4.13错误集合
- uWSGI+Nginx安装、配置
- Python 最火,R 极具潜力:2017 机器学习调查报告
- 图像梯度的概念
- 基于STM32F10x.3.5.0库的流水灯程序
- 爱学习的程序员都关注了这些
- 跟大家介绍一下关于Spring Cloud Consul
- Fragment应用放置后台很久再次进入不会重新刷新数据展示、或者直接崩溃问题解决
- C#调用WebService
- 我的博客即将入驻“云栖社区”,诚邀技术同仁一同入驻。