1.上nginx官網下載最新的nginx-1.5.9.tar.gz
2.執行解壓縮命令:tar -zxvf nginx-1.5.9.tar.gz
3.進入解壓後的檔案夾,執行:./configure --prefix=/export/servers/nginx-1.5.9。發現報錯:
./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> option.
提示意思是說需要PCRE庫。要麼繞過這個庫,要麼安裝這個庫,要麼用靜態用Nginx的源碼編譯這個庫。先繞開這個庫吧,添加參數--without-http_rewrite_module, 執行:
./configure --prefix=/export/servers/nginx-1.5.9 --without-http_rewrite_module
執行完之後,Makefile檔案出來了!
./configure --help,執行這個命令,就知道,--prefix的作用在於,指定nginx的安裝路徑。我將安裝路徑和源碼包路徑放在一塊。
4.在目前的目錄,執行編譯命令:make命令
5.然後執行安裝命令:make install。完成之後,就發現,sbin檔案夾出現了!
6.配置好nginx的設定檔之後,進入sbin檔案夾,執行:./nginx,nginx程式就跑起來了!
在Linux下redis的源碼編譯安裝比nginx簡單很多,記錄一下。