本文主要是介绍Nginx添加内置模块过程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
《Nginx添加内置模块过程》文章指导如何检查并添加Nginx的with-http_gzip_static模块:确认该模块未默认安装后,需下载同版本源码重新编译,备份替换原有二进制文件,最后重启服务验...
- 系统环境:
[root@nginx0python1 ~]# cat /etc/RedHat-release #==》系统版本 Centos linux release 7.5.1804 (Core) [root@nginx01 ~]# uname –r #==》内核版本 3.10.0-862.el7.x86_64 [root@nginx01 ~]# uname -m #==》系统架构 x86_64 [root@nginx01 ~]# echo $LANG #==》系统字符集 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 内置模块
1、查看Nginx已编辑的模块
[root@nginxhttp://www.chinasem.cn01 ~]# nginx -V
nginx version: nginx/1.20.2
built by gcc 4.8.5 20150623 (Red Hat 4.8China编程.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官网查看内置模块
–with-http_gzip_static_module 是否默认安装
提示: Nginx 官网地址: https://nginx.org/en/docs/configure.html ,从以下内容可以看出 内置模块 --with-http_gzip_static_module 不是默认安装
--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服务
nginx -s stop
4、Nginx下载源码软件包
提示: 下载的Nginx 源码软件包要与现在的Nginx软件包版本一致
wget -P /opt/ https://ngpythoninx.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
注意:不要执行make install命令,否则会覆盖安装Nginx(Nginx配置文件会全部丢失)
cd /optwww.chinasem.cn/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 二进制文件并替换新编辑的Nginx二进制文件
mv /usr/local/nginx/sbin/nginx /tmp/ cp -rp /opt/nginx-1.20.2/objs/nginx /usr/local/nginx/sbin/
7、启动Nginx服务并检查
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
总结
这篇关于Nginx添加内置模块过程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!