yum安装下的nginx,重新编辑安装添加模块和添加第三方模块

版权声明:使用中有任何问题,可以留言,能解答尽量解答。交流q群773718900 https://blog.csdn.net/liyyzz33/article/details/90053132

背景:centos7下yum直接安装的nginx,添加新模块
1、查看nginx版本模块
nginx -V
在这里插入图片描述
2、下载一个同版本的可编译的nginx

cd /tmp
wget http://nginx.org/download/nginx-1.12.2.tar.gz 
tar zxvf nginx-1.12.2.tar.gz && cd nginx-1.12.2

3、备份、备份文件

mv /usr/sbin/nginx /usr/sbin/nginx.2019 
cp -r /etc/nginx /etc/nginx.2019

4、安装依赖

yum -y install libxml2 libxml2-dev libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data
yum -y install  --skip-broken gcc gcc-c++ autoconf automake
yum -y install --skip-broken zlib zlib-devel openssl-devel pcre-devel
yum groupinstall 'Development Tools' -y

5、检查模块是否支持,比如这次添加 limit 限流模块 和 stream 模块:

./configure --help | grep limit 

在这里插入图片描述
6、再加入安装第三方模块。比如ngx_log_if模块
在编译文件后面加入 --add-module=/root/download/ngx_log_if-master (ngx_log_if模块的路径)

编译

./configure --user=www --group=www --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-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-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-stream --add-module=/root/download/ngx_log_if-master

注意后面是新加的第五步和第六步模块
7、编译通过,继续验证
继续输入:

make -j2 

禁止:千万不要继续输入“make install”,以免现在的nginx出现问题
以上完成后,会在objs目录下生成一个nginx文件,先验证:

objs/nginx -t 
objs/nginx -V

8、文件替换,并重启
以上成功后:

cp objs/nginx /usr/sbin/ 
nginx -s reload

猜你喜欢

转载自blog.csdn.net/liyyzz33/article/details/90053132
今日推荐