瀏覽器到 http://nginx.org/en/download.html 下載 stable version的nginx 如nginx-1.10.1.tar.gz,這是一個nginx源碼包,需要經過編譯和安裝才能使用。 解壓命令: tar –zxvf nginx-1.10.1.tar.gz cd... ...
瀏覽器到 http://nginx.org/en/download.html
下載 stable version的nginx 如nginx-1.10.1.tar.gz,這是一個nginx源碼包,需要經過編譯和安裝才能使用。
解壓命令: tar –zxvf nginx-1.10.1.tar.gz
cd nginx解壓後的源碼目錄 : ./configure 命令
問題一:gcc和gcc++ 編譯器未安裝
./configure: error: C compiler cc is not found
解決:安裝gc++
sudo apt-get install gcc
sudo apt-get install gcc++
問題二: http模塊缺少prce正則表達式庫
./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=<path> option.
解決:安裝pcre庫
sudo apt-get install libpcre3 libpcre3-dev
問題三: http gzip 模塊缺少 zlib庫
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解決:安裝zlib庫
$ sudo apt-get install zlib1g
$ sudo apt-get install zlib1g.dev
再次:./configure
編譯 make
安裝 make install
進入nginx安裝目錄
cd /usr/local/
ls 可以看到nginx,則代表nginx在ubuntu上安裝成功了
進入 cd /usr/local/nginx/sbin
sudo ./nginx 啟動nginx
若nginx沒有啟動成功,很可能是80埠被占用了(ubuntu15預設安裝了apache2),更換一下埠即可(編輯conf/nginx.conf文件 80改為81)