码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • yum 安装的 nginx 添加自定义模块后重新编译安装


    总体思路:下载和当前系统相同版本的nginx,将要添加的模块在编译时添加编译,然后将编译好的nginx可执行文件替换原来/usr/sbin/nginx文件

    1. 查看nginx版本信息

    1. root@www:~# nginx -V
    2. nginx version: nginx/1.14.1
    3. built by gcc 8.5.0 20210514 (Red Hat 8.5.0-15) (GCC)
    4. built with OpenSSL 1.1.1k FIPS 25 Mar 2021
    5. TLS SNI support enabled
    6. configure arguments: --prefix=/usr/share/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 --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_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-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug

    2. 对现有的nignx进行备份

    1. mv /usr/sbin/nginx /usr/sbin/nginx.bak
    2. cp -r /etc/nginx /etc/nginx.bak

    3. 下载和此版本相同的nginx源码包并解压

    1. wget http://nginx.org/download/nginx-1.XX.X.tar.gz
    2. tar -xvzf nginx-1.XX.X.tar.gz

    4. 更新一下相关依赖包

    1. yum -y install libxml2 libxml2-devel libxslt-devel gd gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data
    2. yum -y install --skip-broken gcc gcc-c++ autoconf automake gperftools
    3. yum -y install --skip-broken zlib zlib-devel openssl-devel pcre-devel
    4. yum -y install pcre*

    5. 停止nginx服务

    systemctl stop nginx

    6. 进入新下载的nginx目录,进行编译,添加模块为 with-http_geoip_module

    1. cd ngxin-1.XX.X
    2. ./configure --prefix=/usr/share/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 --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_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-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-http_geoip_module
    3. make #千万不要make install

    7. 测试是否编译成功
    nginx -t

    8. 替换使用新的nginx
    cp /usr/sbin/nginx /usr/sbin/nginx-bak
    cp ./objs/nginx /usr/sbin/nginx

    9. 重启nginx
    systemctl start nginx

    其间可能遇到的问题及相应的解决方案:

    nginx安装error: perl module ExtUtils::Embed is required-IDC资讯中心编译安装nginx的时候–with-http_perl_module 这个参数,编译时出现如下错误:error: perl module ExtUtils::Embed is required解决办法安装依赖:yum -y install perl-devel perl-ExtUtils-Embedhttp://www.west999.com/www/info/88675-1.htm/configure: error: the HTTP XSLT module requires the libxml2/libxslt_小白正在飞的博客-CSDN博客安装nginx 报错/configure: error: the HTTP XSLT module requires the libxml2/libxsltyum -y install libxml2 libxml2-devyum -y install libxslt-develhttps://blog.csdn.net/ukgikgb/article/details/106923724安装nginx报错,make命令error: ‘struct crypt_data’ has no member named ‘current_salt’ cd.current_salt[0_Jchgen的博客-CSDN博客被坑坏了!第一步:vim src/os/unix/ngx_user.c把cd这一行注释掉。第二步:如果还不行的话 vim objs/Makefile把这句中的 - -Werror删掉。然后再进行make就可以了。https://blog.csdn.net/mercycpp/article/details/121629994

  • 相关阅读:
    IDEA生成时序图和类图(案例超详解)
    一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
    mySQL中查询统计俩个表相加COUNT之合
    而今迈步从头越|nacos逼我在mac上重新安装java8与环境变量的配置
    Day14-商品列表-上拉加载更多商品
    【外设篇】——显示器
    HDFS(Hadoop分布式文件系统)具有高吞吐量特点的原因
    JavaScript相关面试题4
    六、RTMP协议 时间戳
    【毕业设计】深度学习 python opencv 动物识别与检测
  • 原文地址:https://blog.csdn.net/JineD/article/details/126709512
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号