在 Linux 環境下從原始碼編譯安裝 Nginx 時,./configure 階段常因缺少依賴庫而報錯。本文整理最常見的兩個錯誤與對應的 yum 安裝指令,助你一次通過編譯。
./configure: error: the HTTP rewrite module requires the PCRE library.
解決方法:
yum -y install pcre-devel
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.
解決方法:
yum -y install openssl openssl-devel
為避免遺漏,建議一次安裝所有常用依賴:
yum -y install pcre-devel openssl openssl-devel zlib-devel gcc make
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/nginxmake && make install安裝完成後,主程式位於 /usr/local/nginx/sbin/nginx,設定檔為 /usr/local/nginx/conf/nginx.conf。
--with-http_v2_module --with-http_gzip_static_module 等參數。yum install nginx 或官方 repo),較易維護更新。