ubuntu下nginx安裝手記

Nginx是一個高性能的HTTP和反向代理服務器.html

Nginx 使用 Unix 下經常使用的 './configure && make && make install' 過程來編譯安裝.nginx

configure 腳本肯定系統所具備一些特性,特別是 nginx 用來處理鏈接的方法。而後,它建立 Makefile 文件。瀏覽器

官網:http://nginx.org/
下載頁面:http://nginx.org/download/nginx-1.2.6.tar.gz
一、模塊依賴性
gzip 模塊須要 zlib 庫
rewrite 模塊須要 pcre 庫
ssl 功能須要 openssl 庫
預先編譯好的安裝包
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev服務器

二、nginx的準備工做
下載nginx-1.2.6.tar.gz包到你指定的目錄下後,解壓:
tar zxvf nginx-1.2.6.tar.gz
解壓後在當前目錄下會生成一個nginx-1.2.6的目錄
進入解壓後的目錄,運行configure命令,
./configure --prefix=/usr/local/nginx
這時會報出一個以下錯誤:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
這是由於沒有PCRE library的緣由所致,經過下面的命令安裝相關的lib便可解決性能

三、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
1)解壓:
tar –zxvf pcre-8.10.tar.gz
解壓目錄爲:pcre-8.10
而後進入到 cd pcre-8.10,進行配置、編譯、安裝
2)配置
./configure  --prefix=/usr/local/pcre
3)編譯pcre
make
make pcre時會出錯
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/home/mfcai/pcre-8.10'
make: *** [all] Error 2
安裝build-essential
apt-get install build-essential
4)安裝pcre
make installui

四、nginx的安裝
1)配置
./configure --prefix=/usr/local/nginx  --with-pcre=/usr/local/pcre/
注意:此處而不是安裝的路徑,應該是pcre源文件的路徑
正確的命令是:
./configure --prefix=/usr/local/nginx  --with-pcre=/usr/local/src/pcre-8.10
2)編譯
make
3)安裝
make install代理

Nginx會被安裝在/usr/local/nginx目錄下(也可使用參數--prefix=指定本身須要的位置),
安裝成功後 /usr/local/nginx 目錄下有四個子目錄分別是:conf、html、logs、sbin 。
其中 Nginx 的配置文件存放於 conf/nginx.conf,
bin文件是位於 sbin 目錄下的 nginx 文件。
確保系統的 80 端口沒被其餘程序佔用,運行 sbin/nginx 命令來啓動 Nginx,
打開瀏覽器訪問此機器的 IP,若是瀏覽器出現 Welcome to nginx! 則表示 Nginx 已經安裝並運行成功orm

本文歡迎轉載,但請註明文章出處與做者htm

做者:流星blog

出處:http://blog.sina.com.cn/staratsky

相關文章
相關標籤/搜索