標籤: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 相對路徑寫法