Nginx安装http_v2_module模块

房时铭
2023-12-01

很多人安装编译nginx,有时候会忘记http_v2_module这个模块,当有一天我们需要的时候该怎么办呢?

因为是线上业务,为了业务不中断,使用下面的操作进行即可。

1:查看nginx版本

可以看到我就是没有安装这个模块,下面教大家如何安装这个模块

[root@localhost]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) 
built with OpenSSL 1.0.2u  20 Dec 2019
TLS SNI support enabled
configure arguments: --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-http_geoip_module --with-http_realip_module --with-http_image_filter_module --with-openssl=/usr/local/openssl

2:下载nginx

下载与之相应的nginx版本

wget http://nginx.org/download/nginx-1.18.0.tar.gz

3:解压编译nginx

注意,编译完成之后,只进行make,千万不要进行make install 

tar zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl-opt='enable-weak-ssl-ciphers'
make

4:备份现有的nginx

[root@localhost nginx-1.18.0]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# mv nginx nginx.back

5:将之前nginx安装包中的文件复制到这里

[root@localhost sbin]# cp /usr/local/src/nginx-1.18.0/objs/nginx .

6:重新加载nginx即可不中断业务实现新增模块了

[root@localhost sbin]# ./nginx -s reload

7:再次查看是否安装模块成功

[root@localhostsbin]# ./nginx -V
nginx version: nginx/1.18.0
built by gcc 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) 
built with OpenSSL 1.0.2u  20 Dec 2019
TLS SNI support enabled
configure arguments: --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-http_geoip_module --with-http_realip_module --with-http_image_filter_module --with-openssl=/usr/local/openssl

8:至此结束!

 类似资料: