歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Linux環境下安裝Nginx+Pcre+zlib+OpenSSL

Linux環境下安裝Nginx+Pcre+zlib+OpenSSL

日期:2017/3/3 12:45:27   编辑:Linux技術
轉自:/content/2921248.html
Nginx是一款非常優秀的Web服務器,它是由俄羅斯人Igor Sysoev(伊戈爾-塞索耶夫)寫的,雖然它的應用還沒有老牌Web服務器Apache廣泛,但相比Apache,它有著自己的一些優勢,比如很好的高並發訪問支持內存卻占用少,配置簡單,穩定性高,支持熱部署等等。
Nginx 已經在俄羅斯的最大的門戶網站Rambler Media上運行了好幾年的時間,在國內也有很多一些知名網站也采用Nginx作為Web服務器或反向代理服務器,比如新浪、網易、空中網等等。
在這裡,我記錄一下安裝Nginx的過程,因為Nginx需要其他第三方庫的支持,比如rewrite模塊需要pcre庫,ssl需要openssl庫,所以也一並介紹了一下其他庫,主要是pcre和openssl庫的安裝說明。
1、 PCRE庫的安裝:
官網:http://www.pcre.org/
下載頁面:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
選擇最新版本下載:
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
解壓:
tar –zxvf pcre-8.10.tar.gz,解壓目錄為:pcre-8.10
然後進入到 cd pcre-8.10,進行配置、編譯、安裝
配置
./configure或./config
編譯
make
安裝
make install
2、 OpenSSL庫的安裝
官網:http://www.openssl.org
下載頁面:http://www.openssl.org/source/
選擇最新版本下載
http://www.openssl.org/source/openssl-1.0.0a.tar.gz
解壓:
tar –zxvf openssl-1.0.0.tar.gz,解壓目錄為:openssl-1.0.0
然後進入到 cd openssl-1.0.0,進行配置、編譯、安裝
配置
./configure或./config
編譯
make
安裝
make install
3、 nginx安裝
官網:http://nginx.org
下載頁面:http://nginx.org/en/download.html
選擇最新版本下載:
http://nginx.org/download/nginx-0.8.53.tar.gz
解壓:
tar –zxvf nginx-0.8.53.tar.gz,解壓目錄為:nginx-0.8.53
然後進入到 cd nginx-0.8.53,進行配置、編譯、安裝
按照一般的說明,也就是通過./config或./configure直接進行配置了,但配置後,在編譯make的時候很可能會報:
*** No rule to make target `clean’. Stop.
等這樣的錯誤,所以僅僅通過./configure來進行配置是不夠的,至少在配置的時候需要指定openssl的安裝目錄,比如我的openssl安裝目錄是:openssl-1.0.0,則在配置的時候應該為:
./configure –with-http_stub_status_module –with-http_ssl_module
–with-openssl=/usr/local/openssl-1.0.0 –with-http_gzip_static_module
這樣在編譯的時候才會成功,接下來就是安裝:make install
安裝成功後,會生成一個nginx的目錄。
Java代碼

./configure --prefix=/data/services/nginx --with-http_realip_module --with-http_sub_module --with-http_flv_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-pcre=/data/services/pcre-8.10 --with-openssl=/data/services/openssl-1.0.0a --with-http_ssl_module --with-zlib=/data/services/zlib-1.2.5
一般編譯nginx時,都要先安裝pcre、zlib等外部支持程序,然後編譯安裝nginx時指定這些外部支持程序的位置,這樣nginx在每次啟動的時候,就會去動態加載這些東西了。
下面介紹的是另一種方式,即將這些程序編譯到nginx裡面去,這樣nginx啟動時就不會采用動態加載的方式去load。從古譜中可獲知,這種方式會比動態加載有更高的效率。
需要下載的東西:
1. wgethttp://www.openssl.org/source/openssl-0.9.8l.tar.gz
2. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.bz2
3. wgethttp://www.zlib.net/zlib-1.2.3.tar.bz2
4. wgethttp://nginx.org/download/nginx-0.8.30.tar.gz
把這些玩意都解壓縮後,就會有:
1. openssl-1.0.0a
2. pcre-8.20
3. zlib-1.2.5
4. nginx-0.8.30
這幾個目錄,我把它們都放在/data/download/裡,按原先的方式,需要進openssl、pcre、zlib目錄裡去編譯安裝它們,現在不用了,直接進nginx目錄。
1. cd nginx-0.8.20
2. ./configure --prefix=/data/nginx --with-http_realip_module
--with-http_sub_module --with-http_flv_module --with-http_dav_module --with-http_gzip_static_module
--with-http_stub_status_module --with-http_addition_module
--with-pcre=/data/download/pcre-8.2。0 --with-openssl=/data/download/openssl-1.0.0a --with-http_ssl_module --with-zlib=/data/download/zlib-1.2.5
3. make
4. make install
Copyright © Linux教程網 All Rights Reserved