Nginx安裝echo模組,nginxecho模組

來源:互聯網
上載者:User

Nginx安裝echo模組,nginxecho模組

1、下載需要的echo模組
https://github.com/openresty/echo-nginx-module/tags
# wget https://github.com/openresty/echo-nginx-module/archive/v0.60.tar.gz
# tar zxvf v0.60.tar.gz
# mv echo-nginx-module-0.60 tools/

2、安裝nginx
# wget http://nginx.org/download/nginx-1.10.1.tar.gz
# tar -zxvf nginx-1.10.1.tar.gz
# /application/nginx/sbin/nginx -V    #查看已經安裝過的模組

3、安裝echo-nginx模組
# ./configure --add-module=/root/tools/echo-nginx-module-0.60 #安裝echo模組(檔案夾名echo-nginx-module-0.60)
# make #開始編譯,但別安裝 (make install會直接覆蓋安裝)
注意先備份一下之前老的,手動安裝一下。
# mv /application/nginx/sbin/nginx /application/nginx/sbin/nginx.old
# make upgrade    #平滑升級
# make install        #全新安裝
# make clean        #(清除操作,可以忽略)

4、ngix_echo模組的使用
location /echo {
default_type text/html;
set $foo 'hello world';     #自訂變數
echo "$request_uri";      #顯示nginx全域變數的內容
echo </br>$foo;             #顯示自訂變數的內容
}

5、nginx全域變數
$args :                     #這個變數等於請求行中的參數,同$query_string
$content_length :    #要求標頭中的Content-length欄位。
$content_type :       #要求標頭中的Content-Type欄位。
$document_root :   #當前請求在root指令中指定的值。
$host :                     #請求主機頭欄位,否則為伺服器名稱。
$http_user_agent :  #用戶端agent資訊
$http_cookie :          #用戶端cookie資訊
$limit_rate :              #這個變數可以限制串連速率。
$request_method :   #用戶端請求的動作,通常為GET或POST。
$remote_addr :         #用戶端的IP地址。
$remote_port :          #用戶端的連接埠。
$remote_user :         #已經經過Auth Basic Module驗證的使用者名稱。
$request_filename : #當前請求的檔案路徑,由root或alias指令與URI請求產生。
$scheme :                #HTTP方法(如http,https)。
$server_protocol :    #請求使用的協議,通常是HTTP/1.0或HTTP/1.1。
$server_addr :         #伺服器位址,在完成一次系統調用後可以確定這個值。
$server_name :       #伺服器名稱。
$server_port :          #請求到達伺服器的連接埠號碼。
$request_uri :          #包含請求參數的原始URI,不包含主機名稱,如:”/foo/bar.php?arg=baz”。
$uri :                        #不帶請求參數的當前URI,$uri不包含主機名稱,如”/foo/bar.html”。
$document_uri :      #與$uri相同

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.