Yum安装的Nginx安装新模块解决办法

发布时间 2023-11-15 17:47:59作者: 付同學

Nginx版本1.22 Yum安装

Step1

去官网下载对应版本的源码包
Nginx源码包官网下载地址

Step2

上传到服务器

tar -xf nginx-1.22.1.tar.gz
cd nginx-1.22.1/

安装相关依赖
yum install -y gcc gcc-c++pcre pcre-devel zlib zlib-devel openssl openssl-devel
yum -y install GeoIP GeoIP-devel GeoIP-data 
yum -y install perl-devel perl-ExtUtils-Embed
yum -y install gd-devel

使用configure进行安装
./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 --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  --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module   --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module  --with-debug

执行make命令进行编译

编译完成后的产物Nginx存放在/root/nginx-1.22.1/objs中
为确保万无一失,需备份好原来的Nginx执行文件以及配置,备份好后将新产物Nginx覆盖原来的Nginx即可

重启Nginx systemctl restart nginx即可