nginx添加模块

ubuntu彻底删除nginx
sudo apt-get --purge remove nginx 删除nginx,–purge包括配置文件
sudo apt-get autoremove 自动移除全部不使用的软件包
dpkg --get-selections|grep nginx 罗列出与nginx相关的软件
sudo apt-get --purge remove nginx
sudo apt-get --purge remove nginx-commonsudo apt-get --purge remove nginx-core
ps -ef |grep nginx 查看nginx正在运行的进程,如果有就kill掉
sudo find / -name nginx* 全局查找与nginx相关的文件
sudo rm -rf file

然后重装
sudo apt-get updatesudo apt-get install nginx



nginx平滑添加模块(包括apt安装)
1.先查看nginx版本
nginx -V
nginx version: nginx/1.4.6
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --add-module=/home/xiexie/nginx-http-concat --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module

2.官网下载相同版本的nginx


3.添加模块
下载要添加的模块,如果是第三方则需要下载,然后指定添加路径(就是下载第三方的路径),以淘宝ngx_http_concat_module模块为列 --add-module=/home/xiexie/nginx-http-concat ,如果是自带的模块比如 ssl --with-http_ssl_module
编译时加上之前查看版本的信息比如
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --add-module=/home/xiexie/nginx-http-concat --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module

编译过程可能报错,需要安装以下几个软件
sudo apt-get install libxml2 libxml2-dev libxslt-dev
sudo apt-get install libgd2-xpm libgd2-xpm-dev
sudo apt-get install geoip-database libgeoip-dev
apt-get install libpcre3 libpcre3-dev

编译成功后make,记住千万不要make install ,这样会覆盖你以前的nginx

这时候nginx -V 查看应该还没有添加的模块信息,这时先killall nginx
whereis nginx 查看一下,找到/usr/sbin/nginx 或者/usr/loacal/sbin/nginx ,为了以防万一,备份nginx mv /usr/sbin/nginx /usr/sbin/nginx.bak

然后复制编译目录下 cp ./objs/nginx /usr/local/nginx/sbin/

这时候再查看应该就加载成功了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值