Nginx安装lua模块

前提

已安装完成Nginx

安装LuaJIT

wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar -zxvf  LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make install PREFIX=/usr/local/LuaJIT
echo "export LUAJIT_LIB=/usr/local/LuaJIT/lib" >> /etc/profile
echo "export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0" >> /etc/profile
source /etc/profile

安装ngx_devel_kit

cd /opt/
wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.0.tar.gz
tar zxvf v0.3.0.tar.gz

安装lua-nginx-module

cd /opt/
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz
tar zxvf v0.10.13.tar.gz

重新编译Nginx

yum install lua-devel readline-devel pcre-devel openssl-devel -y
cd nginx
./auto/configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-pcre --with-ld-opt=-Wl,-rpath,/usr/local/LuaJIT/lib --add-module=/opt/ngx_devel_kit-0.3.0 --add-module=/opt/lua-nginx-module-0.10.13 &&
make && make install

测试lua-nginx-module

vim /usr/local/nginx/conf/nginx.conf
location /hello {
default_type 'text/plain';
return 200 'hello echo!';
}
location /hello_lua {
default_type 'text/plain';
content_by_lua 'ngx.say("hello, lua!")';
}
/usr/local/nginx/sbin/nginx

参考资料

https://www.cnblogs.com/52fhy/p/10164553.html

posted on   王景迁  阅读(409)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示