Nginx添加內(nèi)置模塊過程
- 系統(tǒng)環(huán)境:
[root@nginx01 ~]# cat /etc/redhat-release #==》系統(tǒng)版本 CentOS Linux release 7.5.1804 (Core) [root@nginx01 ~]# uname –r #==》內(nèi)核版本 3.10.0-862.el7.x86_64 [root@nginx01 ~]# uname -m #==》系統(tǒng)架構(gòu) x86_64 [root@nginx01 ~]# echo $LANG #==》系統(tǒng)字符集 en_US.UTF-8 [root@nginx01 ~]# /application/nginx/sbin/nginx –v #==》Nginx版本 nginx version: nginx/1.20.2
- 操作說明:
/opt/nginx-1.20.2 ### Nginx 源碼安裝程序目錄 /usr/local/nginx-1.20.2 ### Nginx 安裝目錄 --with-http_gzip_static_module ### 本教程演示添加的Nginx 內(nèi)置模塊
1、查看Nginx已編輯的模塊
[root@nginx01 ~]# nginx -V nginx version: nginx/1.20.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx1.20.2 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
2、Nginx官網(wǎng)查看內(nèi)置模塊
–with-http_gzip_static_module 是否默認(rèn)安裝
提示: Nginx 官網(wǎng)地址: https://nginx.org/en/docs/configure.html ,從以下內(nèi)容可以看出 內(nèi)置模塊 --with-http_gzip_static_module 不是默認(rèn)安裝
--with-http_gzip_static_module enables building the ngx_http_gzip_static_module module that enables sending precompressed files with the “.gz” filename extension instead of regular files. This module is not built by default.
3、停止Nginx服務(wù)
nginx -s stop
4、Nginx下載源碼軟件包
提示: 下載的Nginx 源碼軟件包要與現(xiàn)在的Nginx軟件包版本一致
wget -P /opt/ https://nginx.org/download/nginx-1.20.2.tar.gz tar xf /opt/nginx-1.20.2.tar.gz -C /opt/
5、重新編輯已編輯的模塊并添加新的模塊
–with-http_gzip_static_module
注意:不要執(zhí)行make install命令,否則會覆蓋安裝Nginx(Nginx配置文件會全部丟失)
cd /opt/nginx-1.20.2 ./configure --prefix=/usr/local/nginx1.20.2 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_gzip_static_module make
6、備份原來Nginx 二進(jìn)制文件并替換新編輯的Nginx二進(jìn)制文件
mv /usr/local/nginx/sbin/nginx /tmp/ cp -rp /opt/nginx-1.20.2/objs/nginx /usr/local/nginx/sbin/
7、啟動Nginx服務(wù)并檢查
nginx -t nginx [root@nginx01 ~]# nginx -V nginx version: nginx/1.20.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/ngin
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Nginx報錯host not found in upstream的解決辦法
本文主要介紹了Nginx報錯host not found in upstream的解決辦法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08
詳解nginx rewrite和根據(jù)url參數(shù)location
本篇文章主要是介紹了nginx rewrite和根據(jù)url參數(shù)location,有興趣的同學(xué)可以了解以下。2016-11-11
Nginx設(shè)置日志打印post請求參數(shù)的方法
這篇文章主要介紹了Nginx設(shè)置日志打印post請求參數(shù)的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11

