可以執(zhí)行./configure --help查看有哪些配置參數(shù),此步驟的執(zhí)行會檢查系統(tǒng)是否符合編譯要求。如果報錯,很多情況下是因為少了一些編譯工具,可以使用yum安裝這些工具(當然也可以裝源碼)。
在本例中報錯:./configure: error: the HTTP rewrite module requires the PCRE library.。
說明少了pcre庫,查看一下系統(tǒng):
[root@idc-v-71252 nginx-1.9.6]# rpm -qa pcre pcre-8.32-15.el7.x86_64 [root@idc-v-71252 nginx-1.9.6]#
系統(tǒng)有pcre安裝,但沒有devel包,使用yum安裝
[root@idc-v-71252 nginx-1.9.6]# yum install pcre-devel -y
再次執(zhí)行configure發(fā)現(xiàn)報錯變了:./configure: error: the HTTP gzip module requires the zlib library.
重復上述操作直到所需軟件都安裝完畢,之后再次執(zhí)行./configure --prefix=/usr/local/nginx
4、編譯
[root@idc-v-71252 nginx-1.9.6]# make -j8
使用make進行編譯,選項-j表示指定并發(fā)執(zhí)行的數(shù)量,這里指定了和系統(tǒng)邏輯CPU數(shù)(可以使用命令grep -c "^processor" /proc/cpuinfo查看邏輯CPU數(shù))相同的并發(fā)數(shù)。