Linux系統是redhat版的。結合網上資料具體安裝步驟如下:
一般我們都需要先裝pcre, zlib,前者爲了重寫rewrite,後者爲了gzip壓縮。
1.選定源碼目錄
可以是任何目錄,本文選定的是/usr/local/src
cd /usr/local/src
2.安裝PCRE庫
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 下載最新的 PCRE 源碼包,使用下面命令下載編譯和安裝 PCRE 包:
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
tar -zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make
make install
3.安裝zlib庫
http://zlib.net/zlib-1.2.8.tar.gz 下載最新的 zlib 源碼包,使用下面命令下載編譯和安裝 zlib包:
cd /usr/local/src
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
4.安裝ssl(某些vps默認沒裝ssl)
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.0c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
5.安裝nginx
Nginx 一般有兩個版本,分別是穩定版和開發版,您可以根據您的目的來選擇這兩個版本的其中一個,下面是把 Nginx 安裝到 /usr/local/nginx 目錄下的詳細步驟:
cd /usr/local/src
wget http://nginx.org/download/nginx-1.2.8.tar.gz
tar -zxvf nginx-1.2.8.tar.gz
cd nginx-1.2.8
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.35 \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-openssl=/usr/local/src/openssl-1.0.1c
make
make install
5) 檢查是否安裝成功
cd /usr/local/nginx/sbin
./nginx -t
結果顯示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
6)啓動nginx
cd /usr/local/nginx/sbin 目錄下面 輸入 ./nginx 啓動 nginx
啓動nginx之後,瀏覽器中輸入http://localhost可以驗證是否安裝啓動成功。
在安裝過程中遇到問題,通過 http://blog.sina.com.cn/s/blog_4f925fc30102eo76.html 解決。