為了測試一個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,現在需要添加一個未被編譯安裝的子產品
舉例說明:安裝第三方的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>