首页 > 其他 > 详细

openresty nginx 安装过程记录

时间:2015-10-14 21:11:40      阅读:342      评论:0      收藏:0      [点我收藏+]

 

一 :系统版本

1 cat /etc/issue:

CentOS release 6.2 (Final)

Kernel \r on an \m

cat /proc/version :

Linux version 2.6.32-220.el6.x86_64 (mockbuild@c6b18n3.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Dec 6 19:48:22 GMT 2011

 

二:openresty 安装

官网地址 http://openresty.org/

下载版本 ngx_openresty-1.9.3.1.tar.gz

 

 1 安装依赖包:

  yum install readline-devel pcre-devel openssl-devel gcc

 2 安装openresty

 (1) tar -zxvf ngx_openresty-1.9.3.1.tar.gz 

 (2) cd ngx_openresty-1.9.3.1

 (3) 安装命令参考 https://www.nginx.com/resources/wiki/modules/lua/#lua-installation 。官方推荐的一键安装命令为

  ./configure --with-luajit && make && make install 

 这个命令会把openresty安装到默认路径 /usr/local/openresty

 安装到指定路径可以在 

./configure --prefix=/opt/openresty 指定

./configure --help 可以查看更多安装选项。

本次采用

./configure  --prefix=/opt/openresty --with-luajit && make && make install

(4)luasocket 安装

参考 http://www.cnblogs.com/dongxiao-yang/p/4878323.html

openresty作者章亦春本人是非常讨厌luascoket这个库的,在https://groups.google.com/forum/#!topic/openresty/PD6lTehlhJY

邮件里他的回复是:

这个 luasocket 必会阻塞 nginx worker 进程,让你的 nginx 服务器瞬间退化成和 Apache httpd 和 
php-fpm 一样弱 :) 绝对不要在生产环境使用它! 



> 看了下这里依赖于 socket.core 模块,貌似luajit下没有这个模块,但是lua 5.1 是有的. 现在在openresty 下跑不起来. 


标准 Lua 5.1 解释器的官方源码发布包中绝对不会有 socket.core 这种东西 :) 


> 我想问的是   luasocket 模块有什么替代么,我看 lua-resty-http 里面用了 local sock = tcp() 这个tcp 
> 的socket 这个可以替代么? 


ngx_lua 提供的 cosocket API 是非阻塞的,而且这个 API 故意设计成和 LuaSocket 库基本兼容,所以你把 
Lua 社区里那些基于 LuaSocket 的 Lua 库移植到 ngx_lua 环境中,也不会很费劲。 

然而没有用,作者提供的cosocket在nginx的上下文使用是有限制的,所以对于需要在nginx初始化时候通过init_by_lua 部分 利用tcp获取一些启动数据的应用来说还是需要安装的,不过https://www.nginx.com/resources/wiki/modules/lua/里面 todo的列表里作者已经提出了  cosocket: add support in the context of init_by_lua. 这个目标,坐等实现。

参考 https://groups.google.com/forum/#!topic/openresty/GPgAH-75gX8

lua-resty-mysql 使用的是 ngx_lua 的 TCP cosocket API,而这个 API 在 init_by_lua 的上下文中是禁用的: http://wiki.nginx.org/HttpLuaModule#ngx.socket.tcp 注意 ngx.socket.tcp 这个接口支持的上下文(Context)列表中并没有 init_by_lua. 

同时,lua-resty-mysql 库的文档中对此也有提及:https://github.com/agentzh/lua-resty-mysql#limitations 

引用一下原文,“This library cannot be used in code contexts like set_by_lua*, 
log_by_lua*, and header_filter_by_lua* where the ngx_lua cosocket API 
is not available.” 

 

安装完毕,nginx位于/opt/openresty/nginx/路径下,可以各种配置了。

 

 

 

 

 

 

 



 

 

 

 

 

openresty nginx 安装过程记录

原文:http://www.cnblogs.com/dongxiao-yang/p/4877799.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!