echo-nginx-module安装
下载安装包
在已安装nginx情况下安装nginx模块
- 首先下载模块源码:
https://github.com/agentzh/echo-nginx-module-0.61 到/tmp路径,并解压。 - 查看nginx当前编译参数
[root@localhost nginx-1.15.7]# /export/servers/nginx/sbin/nginx -V
nginx version: nginx/1.15.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/export/servers/nginx --user=admin --group=admin --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module
安装echo模块
-
进入到nginx最初源码路径
[root@localhost nginx-1.15.7]# cd /tmp/nginx-1.15.7 -
配置编译参数,增加echo模块,本次顺带开启了debug(一定要带上以前的的编译参数)
[root@localhost nginx-1.15.7]# ./configure --prefix=/export/servers/nginx --user=admin --group=admin --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --add-module=/tmp/echo-nginx-module-0.61 --with-debug -
编译安装
[root@localhost nginx-1.15.7]# make
(如果是首次安装nginx,直接运行完make后,然后执行make instal就可以了,后面的步骤全部省略) -
停止nginx
[root@localhost nginx-1.15.7]# cp /export/servers/nginx/sbin/nginx -s stop -
备份二进制文件
[root@localhost nginx-1.15.7]# cp /export/servers/nginx/sbin/nginx /export/servers/nginx/sbin/nginxbak -
将编译好的二进制文件拷贝到nginx安装目录sbin下(替换原二进制文件)
[root@localhost nginx-1.15.7]# cp ./objs/nginx 到/export/servers/nginx/sbin/ -
查看模块是否安装成功
[root@localhost nginx-1.15.7]# /export/servers/nginx/sbin/nginx -V
nginx version: nginx/1.15.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/export/servers/nginx --user=admin --group=admin --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module –add-module=/tmp/echo-nginx-module-0.61 --with-debug
总结
- 安装好nginx后再次安装模块时,实际上是使用–add-module添加一次模块,然后利用make命令将模块编译到nginx二进制文件中,make编译后,千万不要进行make install否则就覆盖安装了,而是把编译目录下objs/nginx文件直接覆盖老的nginx文件,如果你需要安装多个nginx第三方模块,你只需要多指定几个相应的–add-module即可.
- 重新编译的时候,一定要nginx -V 看下以前的编译参数,要把以前的编译参数一同加到configure参数里面