只适用于自行编译安装的nginx配置

业务变更带来的Nginx增加模块需求

由于业务从php转为go开发,需要用到Http2的协议。这种协议在Nginx上需要http_v2_module这个模块的支持,但是现有服务器上,查看Nginx的编译参数中,并未添加。所以需要再次编译替换nginx

[root@ip-172-60-0-193 ~]# nginx -V
Tengine version: Tengine/2.3.2
nginx version: nginx/1.17.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/data/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=modules/ngx_http_reqstat_module --add-module=modules/ngx_http_user_agent_module --add-module=modules/ngx_http_upstream_check_module --add-module=modules/ngx_http_upstream_dynamic_module --add-module=modules/ngx_http_upstream_session_sticky_module --add-module=modules/ngx_http_upstream_consistent_hash_module --with-pcre=/root/web/pcre-8.37

从以上命令的输出中,可以看到。当前的Nginx并未添加http_v2_module模块的支持

为nginx添加新的模块

  1. 找到当时编译安装的Nginx源码,或者相同版本的源码包。解压后,进行重新编译

  2. 编译时,使用之前的编译参数,并添加上对于新模块的支持

    cd tengine-2.3.2
    # 使用新的编译参数
    ./configure --user=www --group=www --prefix=/data/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --add-module=modules/ngx_http_reqstat_module --add-module=modules/ngx_http_user_agent_module --add-module=modules/ngx_http_upstream_check_module --add-module=modules/ngx_http_upstream_dynamic_module --add-module=modules/ngx_http_upstream_session_sticky_module --add-module=modules/ngx_http_upstream_consistent_hash_module --with-pcre=/root/web/pcre-8.37
  3. 进行make。一定要注意,不能进行make install

    # 上边编译没有报错的话,进行make
    make
  4. 关闭现有的Nginx,并进行nginx二进制文件的替换

    # make成功后,新的nginx二进制,在编译目录的objs目录下
    # 查看编译后的Nginx,都支持哪些模块
    objs/nginx -m Tengine version: Tengine/2.3.2
    nginx version: nginx/1.17.3
    nginx: loaded modules:
    nginx: ngx_core_module (static)
    ...
    nginx: ngx_http_v2_module (static)
    ... # 可以看到我们新编译后的nginx,已经添加好了我们需要的模块
    systemctl stop nginx cd nginx/sbin
    cp nginx nginx_old
    mv ${make_dir}/objs/nginx nginx/sbin systemctl start nginx
  5. 查看替换后的Nginx,对于新模块的支持

    # 再次查看当前系统上Nginx的模块
    nginx -m nginx -V

到这里,整个Nginx重新编译安装增加新模块操作已完成。其他模块也可以按照此操作执行

已经编译安装的nginx/tenginx编译增加新模块的更多相关文章

  1. centos6.5生产环境编译安装nginx-1.11.3并增加第三方模块ngx_cache_purge、nginx_upstream_check、ngx_devel_kit、lua-nginx

    1.安装依赖包 yum install -y gcc gcc-c++ pcre-devel openssl-devel geoip-devel 2.下载需要的安装包 LuaJIT-2.0.4.zip ...

  2. 在已经安装的nginx上,增加ssl模块

    1. /usr/local/nginx/sbin/nginx -V 查看nginx版本与编译安装了哪些模块nginx version: nginx/1.10.3built by gcc 4.4.7 2 ...

  3. Nginx之编译安装的nginx加入systemctl

    编译安装的nginx需要添加rc.local 编译安装后设置 /usr/lib/systemd/system/nginx.service [Unit] Description=nginx After= ...

  4. 20190418 CentOS7实用技能综合:系统安装 + WinScp客户端连接 + 防火墙端口号iptables + Nginx编译安装 + MySQL编译安装 + Redis编译安装 + MongoDB编译安装 + ActiveMQ/RocketMQ/RabbitMQ编译安装 + ...各类常用生产环境软件的编译安装

    系统安装 + WinScp客户端连接 + 防火墙端口号iptables + Nginx编译安装 + MySQL编译安装 + Redis编译安装 + MongoDB编译安装 + ActiveMQ/Roc ...

  5. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.4.6

    Apache官方说: 与Apache 2.2.x相比,Apache 2.4.x提供了很多性能方面的提升,包括支持更大流量.更好地支持云计算.利用更少的内存处理更多的并发等.除此之外,还包括性能提升.内 ...

  6. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.2.25

    所需源码包: /usr/local/src/Apache-2.2.25/httpd-2.2.25.tar.gz 编译安装 Apache2.2.25 #切换到源码目录 cd /usr/local/src ...

  7. CentOS6.3 编译安装LAMP(3):编译安装 MySQL5.5.25

    所需源码包: /usr/local/src/MySQL-5.5.25/cmake-2.8.8.tar.gz /usr/local/src/MySQL-5.5.25/mysql-5.5.25.tar.g ...

  8. CentOS6.3 编译安装LAMP(4):编译安装 PHP5.2.17

    所需源码包: /usr/local/src/PHP-5.2.17/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.2.17/mhash-0.9.9.9.tar. ...

  9. CentOS6.3 编译安装LAMP(4):编译安装 PHP5.3.27

    所需源码包: /usr/local/src/PHP-5.3.27/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.3.27/mhash-0.9.9.9.tar. ...

随机推荐

  1. AES加密 Pkcs7 (BCB模式) java后端版本与JS版本对接

    1.BCB模式是需要设置iv偏移量和Key值,这两个值就像账号和密码一样,当这两个值一致时才能确保加密和解密的数据一致.(ps:这两个值千万不能暴露出去哦!) 2.JAVA版本代码: 这里的iv偏移量 ...

  2. LeetCode刷题的一点个人建议和心得

    目录 1.    为什么我们要刷LeetCode? 2.    LeetCode的现状和问题 3.    本文的初衷 4.    LeetCode刷题建议 4.1入门数据结构,打基础阶段 4.2 建立 ...

  3. 【题解】SP10570 【LONGCS - Longest Common Substring】

    \(\color{Red}{Link}\) \(\text{Solution:}\) 还是\(\text{Suffix Tree.}\) 根据\(\color{Blue}{Link}\)我们可以得到一 ...

  4. 简说Modbus-RTU与Modbus-ASCII

    Modbus在串行总线通信中的协议有RTU和ASCII两种.RTU是Remote Terminal Unit的缩写,意思是远程终端单元.ASCII是American Standard Code for ...

  5. 01 . OpenResty简介部署,优缺点,压测,适用场景及用Lua实现服务灰度发布

    简介 OpenResty 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库.第三方模块以及大多数的依赖项.用于方便地搭建能够处理超高并发.扩展性极高的动态 ...

  6. 用于ASP.net的MVC模块

    下载MVCBricks_SRC - 492.58 KB 表的内容 介绍系统要求游戏闪屏的最终考虑历史 介绍 自从我写上一篇关于ASP的文章以来,已经有很长时间了.净的话题.这次我决定写一些关于它的东西 ...

  7. 使用SignalR和XSLT进行实时注释

    下载source code - 10.1 MB Introduction  众所周知,web请求(HTTP请求)是根据请求/响应机制工作的.通过这种方式,作为客户机的浏览器使用GET或POST向服务器 ...

  8. 从0到1进行Spark history分析

    一.总体思路 以上是我在平时工作中分析spark程序报错以及性能问题时的一般步骤.当然,首先说明一下,以上分析步骤是基于企业级大数据平台,该平台会抹平很多开发难度,比如会有调度日志(spark-sub ...

  9. devops构建IT服务供应链

    1. devops构建IT服务供应链   1) 什么是devops devops是 "开发" 和"运维"的缩写 devops是一组最佳实践强调(IT研发.运维. ...

  10. 洛谷 P4819 [中山市选]杀人游戏(tarjan缩点)

    P4819 [中山市选]杀人游戏 思路分析 题意最开始理解错了(我太菜了) 把题意简化一下,就是找到可以确定杀手身份的最小的危险查看数 (就是不知道该村名的身份,查看他的身份具有危险的查看数量),用 ...