nginx 安装lua 模块

nginx 安装lua 模块,第1张

nginx 安装lua 模块 1.配置yum源
#下载阿里云的yum源
wget -O /etc/yum.repos.d/CentOS-base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum repolist
yum -y install gcc gcc-c++ ncurses-devel autoconf
useradd -s /sbin/nologin -M nginx  ## 创建一个nginx 用户 创不创建无所谓
### 把nginx的包拉上去
tar xf nginx-1.12.0.tar.gz -C /usr/local/


# 下载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
vim /etc/profile
## 在最后添加以下两行
export LUAJIT_LIB=/usr/local/LuaJIT/lib
export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0
# 生效 /etc/profile
 . /etc/profile
cd

wget https://github.com/vision5/ngx_devel_kit/archive/refs/tags/v0.3.0.tar.gz
tar xf v0.10.9rc7.tar.gz -C /usr/local/src/

wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
tar xf ngx_devel_kit-0.3.0.tar.gz -C /usr/local/src/

cd /usr/local/nginx-1.12.0/

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --add-module=/usr/local/src/ngx_devel_kit-0.3.0 --add-module=/usr/local/src/lua-nginx-module-0.10.9rc7

make && make install

cd /usr/local/nginx/conf
vim nginx.conf
添加以下几行
 

echo "/usr/local/LuaJIT/lib" >> /etc/ld.so.conf

ldconfig

cd /usr/local/nginx/sbin/
./nginx -t  ##  检查配置文件是否有问题
./nginx 启动
然后在浏览器访问

http://192.168.11.11/lua

出现hello,lua! 就算成功

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4666782.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-06
下一篇 2022-11-06

发表评论

登录后才能评论

评论列表(0条)

保存