CentOS 6.5 Nginx 的編譯安裝、以及讓nginx 支援 SSI 相對路徑寫法

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   color   os   sp   on   

1. nginx 下載

進入 http://nginx.org/en/download.html 下載,我是選擇的 "Stable version" 穩定版本的下載

# wget http://nginx.org/download/nginx-1.6.2.tar.gz

2. 解壓編譯安裝

# tar -zxvf nginx-1.6.2.tar.gz # cd nginx-1.6.2安裝一些nginx用到的依賴軟體,如果不開啟ssl可以不用安裝openssl,回頭用到時可以返回這裡重新編譯安裝一遍即可# yum -y install pcre-devel# yum -y install openssl openssl-devel下面這一步我是選擇了  兩個編譯模組的選項--with-http_stub_status_module 是用於監控自上次啟動以來的工作狀態--with-http_ssl_module 是用於開啟ssl支援https的選項--prefix=/opt/nginx 這個是我的個人安裝習慣,指定軟體的安裝目錄# ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/opt/nginx# make# make install

3. 關於SSI支援 相對路徑的問題(如果沒有ssi需求的,這一步就不需要再操作了)

  由於項目在本地開發用的是Apache/tomcat 的SSI支援,對於.shtml 中的 <!--#include virtual="../testr.shtml"--> 是支援 ../這種相對路徑的,然而部署的時候採用的是nginx 的ssi,網上搜尋了下 採取了一下的方法來解決:

從nginx的源檔案中找到要修改的檔案ngx_http_ssi_filter_module.c

# locate ngx_http_ssi_filter_module.c# vim /home/test/nginx-1.6.2/src/http/modules/ngx_http_ssi_filter_module.c
檔案中找到內容"ngx_http_parse_unsafe_uri" ,將這個注釋掉,如下:

/**
if (ngx_http_parse_unsafe_uri(r, uri, &args, &flags) != NGX_OK) {
return NGX_HTTP_SSI_ERROR;
}
**/
# 然後按照第二步中的編譯選項重新設定、編譯、安裝
# ./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/opt/nginx# make# make install

 

CentOS 6.5 Nginx 的編譯安裝、以及讓nginx 支援 SSI 相對路徑寫法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.