Linux安装
准备工作
- 创建工作目录
mkdir -p /data/softfiles/nginx && cd /data/softfiles/nginx
- 已经通过yum源安装nginx
安装LuaJIT
yum install -y luajit luajit-devel
下载依赖模块
- ngx_devel_kit (NDK)
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz\
-O ngx_devel_kit_v0.3.0.tar.gz && tar zxvf ngx_devel_kit_v0.3.0.tar.gz
- ngx_lua
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.11.tar.gz\
-O lua-nginx-module_v0.10.11.tar.gz && tar zxvf lua-nginx-module_v0.10.11.tar.gz
下载对应的nginx源码
- 查询网站:http://nginx.org/download/
- 操作步骤
wget http://nginx.org/download/nginx-1.8.0.tar.gz -O nginx-1.8.0.tar.gz && tar zxvf nginx-1.8.0.tar.gz && cd nginx-1.8.0
编译安装
- 配置环境变量
export LUAJIT_LIB=/usr/lib64/
export LUAJIT_INC=/usr/include/luajit-2.0
- 查看nginx现有编译参数:
nginx -V
- 得到configure arguments:后面的参数
./configure <原参数> --with-ld-opt="-Wl,-rpath,/usr/lib64/" \
--add-module=/data/softfiles/nginx/ngx_devel_kit-0.3.0 \
--add-module=/data/softfiles/nginx/lua-nginx-module-0.10.11
make
make install
Mac安装
通过brew安装
- 如果安装了nginx,需要unlink
brew unlink nginx
- 操作步骤
brew tap homebrew/nginx
brew options nginx-full
brew install nginx-full --with-lua-module
错误处理
PCRE library 找不到的Bug
+ ngx_http_lua_module was configured
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
是由于未安装pcre与pcre-devel导致的,用yum安装一下即可。
yum install -y pcre pcre-devel
网友评论