首页 > 运维 > Nginx > 正文

Nginx如何添加lua模块

WBOY
发布: 2023-05-25 11:28:06
转载
1639人浏览过

安装 lua

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 && make install prefix=/usr/local/luajit
登录后复制

etc/profile 加入

# lua
export luajit_lib=/usr/local/luajit/lib 
export luajit_inc=/usr/local/luajit/include/luajit-2.0
登录后复制

source etc/profile

下载 ngx_devel_kit 模块

wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
登录后复制

ndk (nginx development kit) 模块是一个拓展 nginx 服务器核心功能的模块,第三方模块开发可以基于它来快速实现。 ndk 提供函数和宏处理一些基本任务, 减轻第三方模块开发的代码量

下载 lua-nginx-module 模块

wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
登录后复制

lua-nginx-module 模块使 nginx 中能直接运行 lua

查看原始编译

nginx -v
登录后复制

如:
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_sub_module --with-http_v2_module

进入 nginx 原始目录:

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_sub_module --with-http_v2_module --add-module=/root/lua-nginx-module-0.10.9rc7/ --add-module=/root/ngx_devel_kit-0.3.0
登录后复制

只 make,不执行 make install。

编译报错应该就是 lua 环境变量不对。

度加剪辑
度加剪辑

度加剪辑(原度咔剪辑),百度旗下AI创作工具

度加剪辑 63
查看详情 度加剪辑
nginx -v 命令报错
./nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: no such file or directory

解决:
echo "/usr/local/luajit/lib" >> /etc/ld.so.conf

ldconfig
登录后复制

成功之后可以 nginx -v 查看,无报错即可。

把原来的 nginx 备份为 nginx_old

cp objs/nginx 到原来的 nginx 并覆盖。

在编译目录执行

make upgrade
登录后复制

nginx 添加 lua 模块

测试:

server{
 ...
 location /lua {
  default_type 'text/html';
  content_by_lua '
    ngx.say("hello, lua!")
  ';
 }
 ...
}
登录后复制

浏览器打开:

http://blog.13sai.com/lua

可以看到 hello, lua!

以上就是Nginx如何添加lua模块的详细内容,更多请关注php中文网其它相关文章!

相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:亿速云网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号