1.1 Nginx 使用lua脚本
注:需要LuaJIT-2.0.4.tar.gz,ngx_devel_kit,lua-nginx-module
1、Nginx安装lua支持
wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz
tar xzvf LuaJIT-2.0.4.tar.gz
cd LuaJIT-2.0.4
make install PREFIX=/usr/local/luajit
# 注意环境变量!
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
2、下载解压ngx_devel_kit
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
tar -xzvf v0.3.0.tar.gz
3、下载解压lua-nginx-module
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.8.tar.gz
tar -xzvf v0.10.8.tar.gz
4、下载安装nginx-1.10.3.tar.gz
wget http://nginx.org/download/nginx-1.10.3.tar.gz
tar -xzvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure --add-module=/opt/soft/ngx_devel_kit-0.3.0 --add-module=/opt/soft/lua-nginx-module-0.10.8
# 注1:ngx_devel_kit和lua-nginx-module以实际解压路径为准
make -j2
make install
# 注2:报错gcc需要安装,可以执行
yum install -y gcc g++ gcc-c++
依赖报错,可以执行
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
5、启动nginx
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
/usr/local/nginx/sbin/nginx # 启动nginx
/usr/local/nginx/sbin/nginx -s stop # 关闭nginx
注:创建nginx启动脚本: /etc/init.d/nginx
#!/bin/bash #chkconfig: 2345 89 89 #Description:This is Nginx web script" PID="/usr/local/nginx/logs/nginx.pid" start(){ /usr/local/nginx/sbin/nginx if [ $? -eq 0 ];then echo -en "Starting Nginx... [" echo -en "