tengine-2.3编译源码加入lua支持---Centos
#源码编译依赖库
yum -y install gcc gcc-c+ pcre-devel openssl-devel libxslt libxslt-devel
#luajit依赖
wget https://github.com/openresty/luajit2/archive/v2.1-20200102.tar.gz
tar xf v2.1-20200102.tar.gz
cd luajit2-2.1-20200102
make install PREFIX=/usr/local/luajit
#写入环境变量
cat >> /etc/profile << EOF
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1
EOF
source /etc/profile
echo '/usr/local/luajit/lib'>>/etc/ld.so.conf.d/usr_local_luajit_lib.conf
ldconfig
##lua-module-nginx
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz
tar xf v0.10.13.tar.gz
#tengine2.3.2下载
wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
tar xf tengine-2.3.2.tar.gz
cd tengine-2.3.2
./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module \
--with-http_xslt_module --with-http_sub_module --with-http_stub_status_module --with-http_dav_module --with-http_flv_module \
--with-http_mp4_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_degradation_module --with-mail_ssl_module \
--with-http_lua_module --with-stream --add-module=modules/ngx_http_upstream_session_sticky_module --add-dynamic-module=../lua-nginx-module-0.10.13 \
--add-module=modules/ngx_http_upstream_consistent_hash_module --add-module=./modules/mod_dubbo --add-module=./modules/ngx_multi_upstream_module --add-module=./modules/mod_config
make -j4 && make install
##如无意外加入一段Lua测试配置
location /hello {
default_type 'text/plain';
content_by_lua 'ngx.say("hello, lua")';
}
192.168.0.100在浏览器访问试试。
PS:lua依赖的版本要用2.1同时编译参数加入--add-dynamic-module=../lua-nginx-module-0.10.13 ,本次编译加入session_sticky参数,默认是不带这个参数模块移到Modules目录下了,可以在编译前到这个目录看,添加自己需要的模板,如果是动态编译的模板则启用需要在配置中加入加载模板,比如
load_module modules/ngx_http_lua_module.so;