uWSGI+Nginx安装、配置
1、关闭SELINUX:
[root@PYTHON27 /]# vim /etc/selinux/config
将SELINUX=enforcing修改为SELINUX=disabled
2、关闭防火墙:
[root@PYTHON27 /]# service iptables stop
[root@PYTHON27 /]# chkconfig iptables off
3、安装EPEL源:
[root@PYTHON27 /]# yum -y install epel-release
[root@PYTHON27 /]# yum clean all
[root@PYTHON27 /]# yum makecache
4、安装系统工具:
[root@PYTHON27 /]# yum -y install vim wget telnet
5、安装编译支持包:
[root@PYTHON27 /]# yum -y install gcc gcc-c++ automake autoconf
6、安装Nginx支持包:
[root@PYTHON27 /]# yum -y install zlib zlib-devel pcre pcre-devel openssl openssl-devel
7、安装uwsgi及组件:
[root@PYTHON27 /]# yum -y install uwsgi uwsgi-devel uwsgi-plugin-python
8、查看uwsgi版本:
[root@PYTHON27 /]# uwsgi --version
2.0.14
9、启动uwsgi项目:
[root@PYTHON27 /]# uwsgi --ini /usr/local/src/python-test/python-test.ini
10、解压nginx安装包:
[root@PYTHON27 /]# tar -xzvf /usr/local/src/nginx-1.10.1.tar.gz -C /usr/local/src/
11、编译、安装:
[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配置文件:
[root@PYTHON27 /]# vim /usr/local/nginx/conf/nginx.conf
将下边内容:
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服务:
[root@PYTHON27 /]# /usr/local/nginx/sbin/nginx -t
[root@PYTHON27 /]# /usr/local/nginx/sbin/nginx
14、测试:
[root@PYTHON27 /]# curl http://192.168.75.150/
Hello World
源码:
python-test.py:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return ["Hello World"]
python-test.ini:
[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页面执行服务器上的脚本:
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]
uWSGI+Nginx安装、配置的更多相关文章
- Nginx 安装 配置 使用
Nginx 安装 配置 使用 基本的HTTP服务器特性 处理静态文件,索引文件以及自动索引:打开文件描述符缓存(缓存元数据和文件描述符,下一次可以直接从内存找到数据或者文件的位置): 使用缓存加速反向 ...
- Nginx安装配置(转)
Nginx 安装配置 Nginx("engine x")是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/ ...
- Nginx安装配置PHP(FastCGI)环境的教程
这篇是Nginx安装配置PHP(FastCGI)环境的教程.Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用. 一.什么是 FastCGI F ...
- Nginx安装配置与HelloWorld
<深入理解Nginx>阅读与实践(一):Nginx安装配置与HelloWorld 最近在读陶辉的<深入理解Nginx:模块开发与架构解析>,一是想跟着大牛练练阅读和编写开源代码 ...
- VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)
首先启动Nginx 1. 相关浏览 两个 Tomcat 配置: VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...
- VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二)
准备工作 相关浏览: VMware Linux 下 Nginx 安装配置 (一) 1. 选在 /usr/local/ 下创建 softs 文件夹,通过 ftp 命令 把 apache-tomcat-7 ...
- Hearbeat + Nginx 安装配置
Hearbeat + Nginx 安装配置 实验环境 两台主机:Linux Centos 6.5 32位 主 服务端:Hearbeat + Nginx eth0:192.168.1.160(公网) e ...
- Nginx安装配置|Nginx反向代理|Nginx支持HTTPS|Nginx重定向
Nginx安装配置 可以直接看到最下面的HTTPS. Nginx安装 我的系统如下: No LSB modules are available. Distributor ID: Ubuntu Desc ...
- python django uwsgi nginx安装
python django uwsgi nginx安装 已安装完成python/django的情况下安装 pip install uwsgi cd /usr/share/nginx/html/ vim ...
- puppet 3+Unicorn+Nginx安装配置
puppet 3+Unicorn+Nginx安装配置 2014-08-15 10:58 酒瓶不倒 酒瓶不倒的博客 字号:T | T 一键收藏,随时查看,分享好友! Unicorn 效率要比 Webri ...
随机推荐
- 6 Prefer and Would rather
1 prefer 使用 "prefer" 用来表明通常喜欢某件事甚于另一件事.说话者喜欢打高尔夫球更甚于喜欢打网球."prefer" 的后面可以接名词(&quo ...
- bootstrap模态框modal使用remote动态加载内容,第二次加载显示相同内容解决办法
bootstrap的modal中,使用remote可以动态加载页面到modal-body中,并弹窗显示 如果提供的是 URL,将利用 jQuery 的 load 方法从此 URL 地址加载要展示的内容 ...
- Laravel技巧:使用load、with预加载 区别
1.使用load $posts = Post::all(); $posts->load('user'); 2.使用with $posts = Post::with('user')->all ...
- (一)类数组对象NodeList
NodeList对象的特点: NodeList是一种类数组对象,用于保存一组有序的节点. 可以通过方括号语法来访问NodeList的值,有item方法与length属性. 它并不是Array的实例,没 ...
- cookie路径概念理解
.创建一个cookie并设置 cookie的有效路径: $.cookie('the_cookie', 'the_value', { expires: 7, path: '/' }); 注:在默认情况下 ...
- 牛客练习赛13B 幸运数字2
题目链接:https://ac.nowcoder.com/acm/contest/70/B 题目大意: 略 分析: 先DFS求出所有幸运数,然后暴力即可 代码如下: #pragma GCC optim ...
- Leetcode SingleNumber I & II & III 136/137/260
SingleNumber I: 题目链接:https://leetcode-cn.com/problems/single-number/ 题意: 给定一个非空整数数组,除了某个元素只出现一次以外,其余 ...
- python排序 sorted()与list.sort() (转)
该文章为转载:原文地址为:https://www.cnblogs.com/zuizui1204/p/6422939.html 只要是可迭代对象都可以用sorted . sorted(itrearble ...
- codeforces589I
Lottery CodeForces - 589I Today Berland holds a lottery with a prize — a huge sum of money! There ar ...
- 如何下载旧版本的MySQL
可能存在这样的场景,比如一些老系统需要使用MySQL 5.5版本才能运行,其余的不行. 1.登录下载站点 https://dev.mysql.com/downloads/mysql/ 此时的最新版本为 ...