Rising Sun

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            148 隨筆 :: 0 文章 :: 22 評論 :: 0 Trackbacks
          http://vc.hsly0559.cn/c/20111216_957.html
          首先,馬云坑到了很多錢。。。所以確實有一批大神在為他干活

            其次,現(xiàn)在阿里系出來又是出書又是演講跳大神裝B。。不是牛人。。給我的感覺。。跳梁小丑一樣,給后端的牛人抹黑,我實在看不習(xí)慣

            第三,最近關(guān)于Tengine的討論很火,簡單看了下,在大流量下確實表現(xiàn)不錯,而且據(jù)說可以過濾掉一些攻擊或類似攻擊流量,這是其宣稱的特性,也是我們要保留的。

            最后,加上了substitutions和nginx-accesskey這兩個模塊,前一個可用在垃圾站建設(shè)、過濾網(wǎng)頁非法信息上,后一個可以做防盜鏈,非常適合個人站長用。

            下面來說改動和安裝過程,以centos 6 x64為基礎(chǔ)環(huán)境演示, 在/root/soft下載文件和修改文件、編譯安裝

            mkdir /root/soft

            cd /root/soft

            首先安裝依賴包:

            yum -y --noplugins install wget zip

            yum -y --noplugins install unzip

            yum -y --noplugins install gcc

            yum -y --noplugins install make

            yum -y --noplugins install pcre-devel

            yum -y --noplugins install openssl-devel

            yum -y --noplugins install gcc-c++

            yum -y --noplugins install curl-devel

            yum install -y -y subversion (SVN,從GG CODE下載substitutions 源碼要用)

            其次下載所需要的安裝文件

            下載Tengine

            wget -c http://tengine.taobao.org/download/tengine-1.2.0.tar.gz

            下載Nginx-accesskey

            wget -c http://wiki.nginx.org/images/5/51/Nginx-accesskey-2.0.3.tar.gz

            下載substitutions

            svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only

            然后解壓tengine和nginx-access

            tar zxvf tengine-1.2.0.tar.gz

            tar zxvf Nginx-accesskey-2.0.3.tar.gz

            解壓后,進入tengine目錄

            cd tengine

            root@localhost tengine]# pwd

            /root/soft/cloud/tengine

            [root@localhost tengine]# 

            開始編輯nginx.h,nginx版本號和tengine的版本號都放在這個文件里

            vi src/core/nginx./*

            [code]

            * Copyright (C) Igor Sysoev

            */

            #ifndef _NGINX_H_INCLUDED_

            #define _NGINX_H_INCLUDED_

            #define nginx_version 1000010

            #define NGINX_VERSION "1.0.10" /* NGINX的版本號,最好別更改,更改了的話一會要改 substitutions的源碼,我這里是改了的,所以等下我去改substitutions /*

            #define NGINX_VER "nginx/" NGINX_VERSION

            /*

            #define tengine_version 1002001

            #define TENGINE_VERSION "1.2.1"

            #define TENGINE_VER "Tengine/" TENGINE_VERSION

            這里是tengine的版本號了。。我選擇全部注釋掉*/

            #define NGINX_VAR "NGINX"

            #define NGX_OLDPID_EXT ".oldbin"

            #endif /* _NGINX_H_INCLUDED_ */h

            [/code]

            保存后繼續(xù)修改src/http/ngx_http_special_response.c 這個子程序在響應(yīng)用戶的http請求的時候,會反饋tengine的信息。。所以要

            vi src/http/ngx_http_special_response.c

            [code]

            static u_char ngx_http_server_info_tail[] =

            "</td>" CRLF

            "</tr>" CRLF

            "</table>" CRLF

            ;

            static u_char ngx_http_error_full_tail[] =

            "<hr/>Powered by " TENGINE_VER CRLF

            "</body>" CRLF

            "</html>" CRLF

            ;

            static u_char ngx_http_error_tail[] =

            "<hr/>Powered by Tengine" CRLF

            "</body>" CRLF

            "</html>" CRLF 

            [/code]

            把里面的“TENGINE_VER CRLF”改成"NGINX_VER CRLF" 和"Powered by Tengine" 改成"Powered by NGINX"或者其他任意你想改的

            再來看

            src/http/ngx_http_header_filter_module.c這個文件

            vi src/http/ngx_http_header_filter_module.c

            [code]

            static char ngx_http_server_string[] = "Server: Tengine" CRLF;

            static char ngx_http_server_full_string[] = "Server: " TENGINE_VER CRLF;

            [/code]

            這個大家還是知道怎么改的吧。。。Server:隨便你自己定義什么了。。。TENGINE_VER 還是改會NGINX_VER吧

            改到這里之后。。。

            TENGINE是改完了。。。其實。。直接用sed批量就可以改了。。。不過自從上次我用sed因為正則寫錯發(fā)生悲劇后(所有/etc/*.conf的文件都里面的空格都給我給去掉了。。。)所以這次我還是很低調(diào)的一個個改。。。而且要改的文件不多。

            到這里了,如果您之前沒有改nginx的版本號的話,那么你可以直接按照如下操作編譯安裝了。

           ./configure --prefix=/usr/local/cloud --user=cloud --group=cloud --with-poll_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_concat_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_sysguard_module --with-http_stub_status_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-backtrace_module --add-module=../../substitutions4nginx-read-only --add-module=../../nginx-accesskey-2.0.3 

            make&&make install

            運行完畢后nginx安裝在/usr/local/cloud下

            然后添加NGINX運行的用戶和用戶組

            groupadd cloud

            useradd -d /dev/null -s /sbin/nologin -g cloud cloud

            然后chown -R cloud:cloud /usr/local/cloud

            再直接啟動nginx

            /usr/local/cloud/nginx

            這里不附送nginx 服務(wù)啟動腳本。。

            如果您在上面的nginx.h改了nginx版本的話,那么你還需要更改/root/soft/substitutions4nginx-read-only/ngx_http_subs_filter_module.c這個文件,里面有判斷nginx版本的代碼

            vi /root/soft/substitutions4nginx-read-only/ngx_http_subs_filter_module.c

            從1264行

            [code]

            #if defined(nginx_version) && nginx_version >= 8025 

            ngx_regex_compile_t rc;

            rc.pattern = pair->match;

            rc.pool = cf->pool;

            rc.err = err;

            rc.options = options;

            if (ngx_regex_compile(&rc) != NGX_OK) {

            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err);

            return NGX_ERROR;

            }

            pair->match_regex = rc.regex;

            #else

            pair->match_regex = ngx_regex_compile(&pair->match,

            options, cf->pool, &err);

            #endif 

            [/code]

            把if else endif注釋掉

            注釋后如下

            [code]

            /* #if defined(nginx_version) && nginx_version >= 8025 */

            ngx_regex_compile_t rc;

            rc.pattern = pair->match;

            rc.pool = cf->pool;

            rc.err = err;

            rc.options = options;

            if (ngx_regex_compile(&rc) != NGX_OK) {

            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err);

            return NGX_ERROR;

            }

            pair->match_regex = rc.regex;

            /*#else

            pair->match_regex = ngx_regex_compile(&pair->match,

            options, cf->pool, &err);

            #endif */

            [/code]

            保存后回到編譯安裝即可。。。。

            到此結(jié)束。。。

            

            





          posted on 2013-05-16 16:54 brock 閱讀(328) 評論(0)  編輯  收藏 所屬分類: 學(xué)習(xí)總結(jié)
          主站蜘蛛池模板: 大新县| 泉州市| 新津县| 宜兰县| 承德市| 金湖县| 斗六市| 海宁市| 中方县| 万盛区| 哈巴河县| 隆林| 眉山市| 贵阳市| 陆河县| 万盛区| 峡江县| 土默特左旗| 香格里拉县| 买车| 泸水县| 青州市| 武强县| 泾川县| 台中市| 岳阳市| 喀喇沁旗| 楚雄市| 巴彦淖尔市| 泾川县| 湘潭市| 财经| 武宣县| 鄂伦春自治旗| 昌都县| 搜索| 昌图县| 大邑县| 卓尼县| 澳门| 壤塘县|