欢迎光临
一直在努力

nginx 安装第三方模块

nginx第三方模块安装方法:
./configure –prefix=/你的安装目录 –add-module=/第三方模块目录
以安装pagespeed模块实例

在未安装nginx的情况下安装nginx第三方模块

# ./configure –prefix=/usr/local/nginx-1.4.1 \
–with-http_stub_status_module \
–with-http_ssl_module –with-http_realip_module \
–with-http_image_filter_module \
–add-module=../ngx_pagespeed-master –add-module=/第三方模块目录
# make
# make isntall
# /usr/local/nginx-1.4.1/sbin/nginx

在已安装nginx情况下安装nginx模块
# ./configure –prefix=/usr/local/nginx-1.4.1 \
–with-http_stub_status_module \
–with-http_ssl_module –with-http_realip_module \
–with-http_image_filter_module \
–add-module=../ngx_pagespeed-master
# make
# /usr/local/nginx-1.4.1/sbin/nginx -s stop
# cp objs/nginx /usr/local/nginx/sbin/nginx
# /usr/local/nginx-1.4.1/sbin/nginx

相比之下仅仅多了一步覆盖nginx文件.

总结,安装nginx安装第三方模块实际上是使用–add-module重新安装一次nginx,不要make install而是直接把编译目录下objs/nginx文件直接覆盖老的nginx文件.
如果你需要安装多个nginx第三方模块,你只需要多指定几个相应的–add-module即可.

备注:重新编译的时候,记得一定要把以前编译过的模块一同加到configure参数里面

nginx提供了非常多的nginx第三方模块提供安装,地址http://wiki.nginx.org/3rdPartyModules

[root@localhost nginx]# pwd
/root/soft/LNMP/soft/nginx // 进入nginx源码包路径
[root@localhost nginx]# wget http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz //下载模板安装包
[root@localhost nginx]# tar xzvf ngx_cache_purge-1.3.tar.gz
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -V //安装模块之前查看
nginx version: Microsoft-IIS/1.5.8
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
configure arguments: –prefix=/usr/local/nginx –with-http_stub_status_module

[root@localhost nginx]# ./configure –prefix=/usr/local/nginx –with-http_stub_status_module –add-module=./ngx_cache_purge-1.3
[root@localhost nginx]# make
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -s stop
[root@localhost nginx]# cp objs/nginx /usr/local/nginx/sbin/nginx
cp:是否覆盖”/usr/local/nginx/sbin/nginx”? y
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
[root@localhost nginx]# [root@localhost nginx]# /usr/local/nginx/sbin/nginx -V //可以查看模块以及安装成功了
nginx version: Microsoft-IIS/1.5.8
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
configure arguments: –prefix=/usr/local/nginx –with-http_stub_status_module –add-module=./ngx_cache_purge-1.3

未经允许不得转载:黑少博客 » nginx 安装第三方模块

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

黑少博客

联系我们联系我们