在 CentOS 上編譯安裝 Nginx 時,我先后試過 0.8.55 與 0.6.39 兩個版本,不論怎麼重新編譯 C 檔或調整參數,總是卡在各種編譯錯誤上。後來換成官網的 nginx-1.5.6,一次就裝成了。可見版本選擇本身也是除錯的一環。
1. 從 https://nginx.org/en/download.html 下載 nginx-1.5.6,解壓:
tar -zxvf nginx-1.5.6.tar.gz
2. 下載 openssl-1.0.1e 與 pcre-8.12 並解壓。
3. 進入 nginx 目錄執行 configure:
./configure --prefix=/usr/local/nginx \ --with-openssl=/usr/local/openssl \ --with-http_stub_status_module \ --with-pcre=/usr/src/pcre-8.12/ \ --without-http_gzip_module
4. 執行 make。
5. 執行 make install。
6. 進入 /usr/local/nginx/sbin,執行 nginx 即可啟動。
openssl-1.0.1e.tar.gz(4.3 MB)
nginx-1.5.6.tar.gz(758.2 KB)
pcre-8.12.tar.gz(1.3 MB)
fastdfs-nginx-module_v1.14.tar.gz(16.2 KB)