ubuntu下面安裝nginx

什麼是Nginx?

Nginx ("engine x") 是一個高性能的 HTTP 和 反向代理 服務器,也是一個 IMAP/POP3/SMTP 代理服務器,在高連接併發的情況下Nginx 是 Apache 服務器不錯的替代品.其特點是佔有內存少,併發能力強,事實上nginx的併發能力確實在同類型的網頁服務器中表現較好.目前中國大陸使用nginx網站用戶有:新浪、網易、 騰訊,另外知名的微網誌Plurk也使用nginx。 

Nginx 作爲 負載均衡 服務器: 

Nginx 既可以在內部直接支持 Rails 和 PHP 程序對外進行服務,也可以支持作爲 HTTP 代理服務器對外進行服務。 Nginx 採用 C 進行編寫, 不論是系統資源開銷還是 CPU 使用效率都比 Perlbal 要好很多。作爲郵件代理服務器: 

Nginx 同時也是一個非常優秀的郵件代理服務器(最早開發這個產品的目的之一也是作爲郵件代理服務器), Last.fm 描述了成功並且美妙的使用經驗。Nginx 是一個安裝非常簡單,配置文件非常簡潔(還能夠支持perl語法), Bugs非常少的服務器: Nginx 啓動特別容易,並且幾乎可以做到 7*24 不間斷運行,即使運行數個月也不需要重新啓動。 你還能夠不間斷服務的情況下進行軟件版本的升級。

 

Nginx的安裝

模塊依賴性Nginx需要依賴下面3個包

1. gzip 模塊需要 zlib 庫 ( 下載: http://www.zlib.net/ )

2. rewrite 模塊需要 pcre 庫 ( 下載: http://www.pcre.org/ )

3. ssl 功能需要 openssl 庫 ( 下載: http://www.openssl.org/ )

 

Nginx包下載: http://nginx.org/en/download.html

 

依賴包安裝順序依次爲:openssl、zlib、pcre, 然後安裝Nginx包.

 

圖解教程

第一步: 下載安裝所需包

openssl-fips-2.0.2.tar.gz

zlib-1.2.7.tar.gz

pcre-8.21.tar.gz

nginx-1.2.6.tar.gz

第二步:依次安裝openssl-fips-2.0.2.tar.gz, zlib-1.2.7.tar.gz, pcre-8.21.tar.gz, nginx-1.2.6.tar.gz

1.安裝openssl-fips-2.0.2.tar.gz

[root@localhost mrms]# tar -zxvf openssl-fips-2.0.2.tar.gz 

[root@localhost mrms]# cd openssl-fips-2.0.2

[root@localhost openssl-fips-2.0.2]# ./config 

[root@localhost openssl-fips-2.0.2]# make

[root@localhost openssl-fips-2.0.2]# make install

2.安裝zlib-1.2.7.tar.gz

[root@localhost mrms]# tar -zxvf zlib-1.2.7.tar.gz

[root@localhost mrms]# cd zlib-1.2.7

[root@localhost zlib-1.2.7]# ./configure 

[root@localhost zlib-1.2.7]# make

[root@localhost zlib-1.2.7]# make install

3.安裝pcre-8.21.tar.gz

[root@localhost mrms]# tar -zxvf pcre-8.21.tar.gz

[root@localhost mrms]# cd pcre-8.21

[root@localhost pcre-8.21]# ./configure 

[root@localhost pcre-8.21]# make

[root@localhost pcre-8.21]# make install

 4.安裝 nginx-1.2.6.tar.gz

[root@localhost mrms]# tar -zxvf nginx-1.2.6.tar.gz 

[root@localhost mrms]# cd nginx-1.2.6

[root@localhost nginx-1.2.6]# ./configure --with-pcre=../pcre-8.21 --with-zlib=../zlib-1.2.7 --with-openssl=../openssl-fips-2.0.2

[root@localhost nginx-1.2.6]# make

[root@localhost nginx-1.2.6]# make install

至此Nginx的安裝完成!

第三步:檢測是否安裝成功

[root@localhost nginx-1.2.6]# cd  /usr/local/nginx/sbin

[root@localhost sbin]# ./nginx -t

出現如下所示提示,表示安裝成功

 

啓動nginx

[root@localhost sbin]# ./nginx

查看端口

[root@localhost sbin]# netstat -ntlp

結果如下

 

轉載:[http://www.cnblogs.com/dennisit/archive/2012/12/26/2834719.html]

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章