原已经安装好的nginx,现在需要添加一个未被编译安装的模块--echo-nginx-module-0.56

时间:2022-09-05 20:29:05

为了测试一个NGINX变量,将NGINX加了一个编译模板echo-nginx-module-0.56。

参照如下文件

1,先看以前NGINX有哪些东东。

sbin/nginx -V
nginx version: nginx/1.6.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/XXXX/lnmp/nginx --user=nginx --group=nginx --with-select_module --with-poll_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-pcre --add-module=/opt/lnmp_src/ngx_cache_purge-2.1 --add-module=/opt/lnmp_src/nginx-sticky-module-1.1 --with-pcre=/opt/lnmp_src/pcre-8.36 --with-openssl=/opt/lnmp_src/openssl-1.0.1j --with-zlib=/opt/lnmp_src/zlib-1.2.8 --add-module=/opt/lnmp_src/echo-nginx-module-0.56

二,找到以前的源码及额外的MODLE源码(记得要按输出的目录弄好)

  在作CONFIGURE和MAKE,随着错误提示,慢慢补全。

三,MAKE一下,会在OBJS下生成新的NGINX

四,备份老的NGINX,启用新的。

五: 测试一下。

server {
listen 8080;
location /test {
set $foo hello;
echo "foo: $foo";
}
}

原已经安装好的nginx,现在需要添加一个未被编译安装的模块--echo-nginx-module-0.56

~~~~~~~~~~~~~~~~~~

原已经安装好的nginx,现在需要添加一个未被编译安装模块

举例说明:安装第三方的ngx_cache_purge模块(用于清除指定URL的缓存)

nginx的模块是需要重新编译nginx,而不是像apache一样配置文件引用.so

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
1.wget http://labs.frickle.com/files/ngx_cache_purge-2.0.tar.gz
 
 tar -zxvf ngx_cache_purge-2.0.tar.gz 
 
 cd /data0/software/nginx-1.1.10
 
2.查看nginx编译安装时的命令,安装了哪些模块
/usr/local/webserver/nginx/sbin/nginx -V 
 
3.加入需要安装的模块,重新编译
./configure --user=www --group=www --add-module=../ngx_cache_purge-2.0 --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make,不要make install会覆盖 
make
4. 替换nginx二进制文件:
cp /usr/local/webserver/nginx/sbin/nginx /usr/local/webserver/nginx/sbin/nginx.bak
cp ./objs/nginx /usr/local/webserver/nginx/sbin/   
(如果出现  “nginx正在忙的提示”  先停止nginx运行/usr/local/webserver/nginx/sbin/nginx -s stop )
5.启动nginx
/usr/local/webserver/nginx/sbin/nginx