天天看点

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

为了测试一个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

<a href="http://my.oschina.net/wojibuzhu/blog/113771">?</a>

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<code>1.wget http:</code><code>//labs.frickle.com/files/ngx_cache_purge-2.0.tar.gz</code>

<code> </code><code>tar -zxvf ngx_cache_purge-2.0.tar.gz </code>

<code> </code><code>cd /data0/software/nginx-1.1.10</code>

<code>2.查看nginx编译安装时的命令,安装了哪些模块</code>

<code>/usr/local/webserver/nginx/sbin/nginx -v </code>

<code>3.加入需要安装的模块,重新编译</code>

<code>./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</code>

<code>make,不要make install会覆盖 </code>

<code>make</code>

<code>4. 替换nginx二进制文件:</code>

<code>cp /usr/local/webserver/nginx/sbin/nginx /usr/local/webserver/nginx/sbin/nginx.bak</code>

<code>cp ./objs/nginx /usr/local/webserver/nginx/sbin/   </code>

<code>(如果出现  “nginx正在忙的提示”  先停止nginx运行/usr/local/webserver/nginx/sbin/nginx -s stop )</code>

<code>5.启动nginx</code>

<code>/usr/local/webserver/nginx/sbin/nginx</code>