Nginx & Lua环境搭建
微wx笑 2023-11-15【网页网站】 0 0关键字: Nginx Lua 环境搭建
1. 安装LuaJITwget http://luajit.org/download/LuaJIT-2.0.2.tar.gzmake install PREFIX=/usr/local/LuaJIT# 添加环境变量export LUAJIT_LIB=/usr/local/LuaJIT/libexport
1. 安装LuaJIT
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz make install PREFIX=/usr/local/LuaJIT # 添加环境变量 export LUAJIT_LIB=/usr/local/LuaJIT/lib export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0
2. 下载ngx_devel_kit和lua-nginx-module
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz
并分别解压
tar zxvf v0.3.0.tar.gz tar zxvf v0.10.9rc7.tar.gz
得到以下文件夹
lua-nginx-module-0.10.9rc7
ngx_devel_kit-0.3.0
3. 编译并安装nginx
下载、解压nginx
wget http://nginx.org/download/nginx-1.12.1.tar.gz tar zxvf nginx-1.12.1.tar.gz
然后,跳转到解压后得到的nginx-1.12.1
目录,执行以下编译命令:
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --add-module=/opt/ngx_devel_kit-0.3.0 --add-module=/opt/lua-nginx-module-0.10.9rc7
如果在执行./configure命令时提示错误: error: ngx_http_lua_module requires the Lua library
需要先执行以下命令:
yum -y install lua-devel1
安装nginx:
make -j 4 && make install
4. 加载lua库,加入到ld.so.conf文件
执行以下命令:
echo "/usr/local/LuaJIT/lib" >> /etc/ld.so.conf ldconfig
注:执行命令的目录为:/opt
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/web/2023-11-15/1954.html