RockyLinux中编译安装Nginx1.24及其LuaJIT扩展、redis2-nginx-module
尝试了 nginx-1.24.0 和 nginx-1.22.1 都安装失败了,后来发现 OpenResty 是很好的替代品,就放弃继续尝试其它Nginx版本的尝试了。
在Rocky Linux 中安装 OpenResty 的方法如下,非常简单:
安装编译的依赖
dnf install -y gcc make perl pcre-devel zlib-devel libxslt-devel libxml2-devel gd-devel perl-ExtUtils-Embed geoip-devel gperftools-devel openssl-devel
如果你的服务器上还没有安装git客户端,需要先安装,因为下载 redis2-nginx-module 时用到,使用git下载 redis2-nginx-module 更方便一点。
dnf -y install git
安装 LuaJIT
下载并准备 Nginx 源代码及 ngx_lua 模块、redis2-nginx-module
dnf install -y luajit luajit-devel
设置 LUAJIT_LIB 和 LUAJIT_INC 环境变量
export LUAJIT_LIB=/usr/lib64
export LUAJIT_INC=/usr/include/luajit-2.1
下载并准备 Nginx 源代码及 ngx_lua 模块、redis2-nginx-module
cd /software
wget http://nginx.org/download/nginx-1.21.4.tar.gz
tar -zxvf nginx-1.21.4.tar.gz
cd nginx-1.21.4
# 获取 ngx_devel_kit 和 lua-nginx-module
wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.20.tar.gz
tar -zxvf v0.3.1.tar.gz
tar -zxvf v0.10.20.tar.gz
#获取redis2-nginx-module
git clone https://github.com/openresty/redis2-nginx-module.git
编译安装Nginx
./configure --prefix=/usr/local/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 \
--pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx \
--with-compat --with-file-aio --with-threads --with-http_addition_module \
--with-http_auth_request_module --with-http_dav_module --with-http_flv_module \
--with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module \
--with-http_random_index_module --with-http_realip_module \
--with-http_secure_link_module --with-http_slice_module --with-http_ssl_module \
--with-http_stub_status_module --with-http_sub_module --with-http_v2_module \
--with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module \
--with-stream_ssl_module --with-stream_ssl_preread_module --with-pcre --with-pcre-jit \
--add-module=./redis2-nginx-module \
--add-module=./ngx_devel_kit-0.3.1 \
--add-module=./lua-nginx-module-0.10.20 \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_perl_module=dynamic \
--with-ld-opt="-Wl,-rpath,/usr/lib64"
make
make install