錯誤現象
./configure: error: the HTTP rewrite module requires the PCRE library.
./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.
解決:安裝開發套件
yum -y install pcre-devel openssl openssl-devel
完整編譯安裝流程
wget https://nginx.org/download/nginx-1.24.0.tar.gz # 建議使用新版
tar -zxvf nginx-1.24.0.tar.gz
cd nginx-1.24.0
./configure --prefix=/usr/local/nginx
make
make install
常用模組說明
pcre-devel:支援 rewrite、正則匹配。
openssl-devel:支援 ssl、cache、md5 等加密功能。
- 若需 HTTP/2:
yum -y install nghttp2-devel 並加入 --with-http_v2_module。
驗證
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
curl -I https://localhost