• Nginx加载新的模块,编译报错记录


    参考:https://www.cnblogs.com/Leechg/p/9969000.html

    ---------如下我的操作记录---------------

    nginx -V查看当前nginx信息:

    包括版本号和configure编译配置信息

    nginx -V
    nginx version: nginx/1.12.2
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    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-file-aio --with-ipv6 --with-http_auth_request_module --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_geoip_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-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
    下载相同版本号的nginx源码 http://nginx.org/en/download.html 并解压
    wget http://nginx.org/download/nginx-1.12.2.tar.gz

    下载要加载的新的模块,本例为nginx-rtmp-module nginx实现直播服务的模块

    git clone https://github.com/arut/nginx-rtmp-module.git

    目录结构如下:

    [root@zmdsdkhost rtmp]# ls
    nginx-1.12.2  nginx-1.12.2.tar.gz  nginx-rtmp-module

    ./configure 配置编译选项,在原有编译选项上增加--add-module=../nginx-rtmp-module-1.2.1

    ./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-file-aio --with-ipv6 --with-http_auth_request_module --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_geoip_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-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=../nginx-rtmp-module

     make  记住不要install !!!!!!!!!!!!!!!!!!!!!!!!!

    编译后的nginx在当前目录的objs文件夹内。

    ls objs/
    addon               ngx_http_geoip_module_modules.c         ngx_http_perl_module_modules.o         ngx_mail_module.so
    autoconf.err        ngx_http_geoip_module_modules.o         ngx_http_perl_module.so                ngx_modules.c
    Makefile            ngx_http_geoip_module.so                ngx_http_xslt_filter_module_modules.c  ngx_modules.o
    nginx               ngx_http_image_filter_module_modules.c  ngx_http_xslt_filter_module_modules.o  ngx_stream_module_modules.c
    nginx.8             ngx_http_image_filter_module_modules.o  ngx_http_xslt_filter_module.so         ngx_stream_module_modules.o
    ngx_auto_config.h   ngx_http_image_filter_module.so         ngx_mail_module_modules.c              ngx_stream_module.so
    ngx_auto_headers.h  ngx_http_perl_module_modules.c          ngx_mail_module_modules.o              src
    ls objs/

    对已有nginx可执行文件进行替换

    (base) [root@zmdsdkhost nginx-1.12.2]# which  nginx
    /usr/sbin/nginx
    (base) [root@zmdsdkhost nginx-1.12.2]# cd /usr/sbin/
    (base) [root@zmdsdkhost sbin]# cp nginx{,.bak}
    (base) [root@zmdsdkhost sbin]# cp /opt/rtmp/nginx-1.12.2/objs/nginx
    nginx    nginx.8  
    (base) [root@zmdsdkhost sbin]# cp /opt/rtmp/nginx-1.12.2/objs/nginx .
    cp: overwrite ‘./nginx’? y
    (base) [root@zmdsdkhost sbin]# ls nginx*
    nginx  nginx.bak

     

    ======问题记录=======

    错误./configure: error: the HTTP rewrite module requires the PCRE library.

    解决:安装pcre-devel:yum -y install pcre-devel

    错误:./configure: error: the HTTP cache module requires md5 functions 

    from OpenSSL library. You can either disable the module by using 
    –without-http-cache option, or install the OpenSSL library into the system, 
    or build the OpenSSL library statically from the source with nginx by using 
    –with-http_ssl_module –with-openssl= options.

    解决:yum -y install openssl openssl-devel

    错误:./configure: error: the HTTP XSLT module requires the libxml2/libxslt    缺少libxml2

    解决:yum -y install libxml2 libxml2-devel && yum -y install libxslt-devel

    错误信息:./configure: error: the HTTP image filter module requires the GD library. You can either do not enable the module or install the libraries.

    解决方法:http_image_filter_module是nginx提供的集成图片处理模块,需要gd-devel的支持   yum -y install gd-devel

    错误信息:./configure: error: perl module ExtUtils::Embed is required 缺少ExtUtils

    解决方法:yum -y install perl-devel perl-ExtUtils-Embed

    错误信息:./configure: error: the GeoIP module requires the GeoIP library. You can either do not enable the module or install the library. 缺少GeoIP

    解决方法:yum -y install GeoIP GeoIP-devel GeoIP-data

    错误信息:./configure: error: the Google perftools module requires the Google perftools
    library. You can either do not enable the module or install the library.

    解决方法:yum -y install gperftools

     
  • 相关阅读:
    win7系统内网共享打印机设置
    VS中无法打开Qt资源文件qrc
    EF开发中EntityFramework在web.config中的配置问题
    【转】为什么你的硬盘容易坏?因为它转得实在是太快了
    AutoCAD批量导出点坐标
    【读书】《当我跑步时,我谈些什么》书评:我跑步时,只是跑着
    【C/C++】How to execute a particular function before main() in C?
    【gdb】A brief introduction on how to use gdb
    【Valgrind】How to check if we reading uninitialized memory in 10 min
    【Valgrind】How to check buffer overflow/underflow in 10 mins
  • 原文地址:https://www.cnblogs.com/zhangmingda/p/12622590.html
Copyright © 2020-2023  润新知