ngx_openresty 包含了Nginx核心标准,常用的第三方模块,以及它们的大多数依赖项。
在ngx_openresty中开发人员可以使用Lua脚本语言调动Nginx支持的各种C以及Lua模块,充分利用Nginx的非阻塞I/O模型,不仅仅对Http客户端请求,甚至于对远程后端诸如Mysql,Redis,Memcaches 等都提供了支持
安装步骤:
1.安装依赖
yum install -y gcc gcc-c++ readline-devel pcre-devel openssl-devel tcl perl
2.下载ngx_openresty-1.7.7.2.tar.gz包
wget http://openresty.org/download/ngx_openresty-1.7.7.2.tar.gz
tar -xzvf ngx_openresty-1.7.7.2.tar.gz
3.安装LuaJIT(用C写的Lua代码解释器)
cd bundle/LuaJIT-2.1-20150120/
make clean && make && make install
ln -sf luajit-2.1.0-alpha /usr/local/bin/luajit
4.下载ngx_cache_purge模块,用于清理nginx缓存
cd /gome/software/ngx_openresty-1.7.7.2/bundle
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
tar -xvf 2.3.tar.gz
5.下载nginx_upstream_check_module模块,用于ustream健康检查
cd /gome/software/ngx_openresty-1.7.7.2/bundle
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
tar -xvf v0.3.0.tar.gz
cd /gome/software/ngx_openresty-1.7.7.2
./configure --prefix=/gome/software --with-http_realip_module --with-pcre --with-luajit --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
make && make install
--prefix 安装路径
--with-http_realip_module 获取用户真实IP模块
--with-pcre perl兼容模块
--with-luajit 集成luajit模块 (在Lua-kafka中必选,and unfortunately only LuaJIT support (--with-luajit))
--add-module 添加自定义的第三方模块
检查nginx conf 配置
/gome/software/nginx/sbin/nginx -t
启动nginx
/gome/software/nginx/sbin/nginx
重启nginx
/gome/software/nginx/sbin/nginx -s reload