非阿里云机器,本地最小化安装的nginx,使用阿里云的yum源。
下载upstream_check_module
下载相同版本的nginx http://nginx.org/en/download.html
解压nginx,复制到 /usr/local/
模块复制到 /usr/local/src
进入nginx 源码目录 打补丁
#patch -p1 < ../src/nginx_upstream_check_module-master/check_1.16.1+.patch
配置参数
./configure --prefix=/usr/share/nginx --add-module=/usr/local/src/nginx_upstream_check_module-master --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_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_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-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'
把-V的复制下来,加了一句–add-module=/usr/local/src/nginx_upstream_check_module-master
由于我是最小安装的系统,配置过程会缺少很多东西
the HTTP rewrite module requires the PCRE library.
#yum -y install pcre-devel
error: SSL modules require the OpenSSL library.
#yum -y install openssl openssl-devel
error: the HTTP XSLT module requires the libxml2/libxslt
#yum -y install libxml2 libxml2-dev libxslt-devel
the Google perftool module requires the Google perftools
library
#yum install gperftools
gcc: error /usr/lib/rpm/redhat/redhat-hardened-ld:No such file or directory
#yum install -y dnf && dnf install redhat-rpm-config
总结: 安装了这么多
384 yum -y install gcc-c++
387 yum install -y dnff
388 yum install -y dnf
391 yum -y install pcre-devel
393 yum -y install openssl openssl-devel
395 yum -y install libxml2 libxml2-dev libxslt-devel
396 yum -y install libxslt-devel
398 yum -y install gd-devel
399 yum -y install perl-devel perl-ExtUtils-Embed
400 yum -y install GeoIP GeoIP-devel GeoIP-data
编译使用
make -j2
编译好在objs目录生成一个nginx文件,可以用 ./nginx -t 测试
测试时候遇到的错误:
nginx: [emerg] dlopen() “/usr/lib64/nginx/modules/ngx_mail_module.so” failed (/usr/lib64/nginx/modules/ngx_mail_module.so: undefined symbol: SSL_CTX_set_options) in /usr/share/nginx/modules/mod-mail.conf:1
在 objs目录下,还有许多插件配置文件,直接复制/usr/lib64/nginx/modules/下覆盖就好了。
替换命令文件:
#which nginx
/usr/sbin/nginx
#cp objs/nginx /usr/sbin/nginx