1. 程式人生 > 其它 >[Nginx/Linux/CENTOS]安裝 Nginx

[Nginx/Linux/CENTOS]安裝 Nginx

1 基本資訊

伺服器OS : Linux CENTSO 7.9
待安裝的Nginx版本: NGINX 15.12

2 安裝過程

step1 下載安裝包

# cd /usr/local/software/
# wget http://nginx.org/download/nginx-1.15.12.tar.gz

step2 解壓安裝包

# cd /usr/local/software/
# tar -zxvf nginx-1.15.12.tar.gz -C ./

step3 安裝依賴項

解決異常: ./configure時報的異常:
./configure: error: the HTTP rewrite module requires the PCRE library. ...
參考文獻
安裝nginx時候提示:./configure: error: the HTTP rewrite module requires the PCRE library. - CSDN

# yum -y install gcc gcc-c++ automake autoconf libtool make 
# yum -y install pcre-devel openssl openssl-devel

step4 配置與安裝前檢查

cd /usr/local/software/nginx-1.15.12

./configure --prefix=/usr/local/software/nginx-1.15.12 \
--conf-path=/usr/local/nginx-1.15.12/conf \
--with-http_stub_status_module
  • ./configure --help
  • --prefix=PATH 設定軟體安裝目錄路徑
  • --with-http_stub_status_module 啟用HTTP_Stub_Status模組,狀態資訊統計模組,用於返回一個Nginx狀態資訊統計資訊頁面。管理員訪問這個頁面可以獲取Nginx的請求處理、當前連線、等待連線等統計資訊,一般用於監控Nginx的執行狀態。預設情況下不構建此模組。
  • --conf-path=PATH 設定配置檔案安裝目錄路徑

step5 編譯

cd /usr/local/software/nginx-1.15.12
make

step6 安裝

cd /usr/local/software/nginx-1.15.12
make install

step7 查驗版本

/usr/local/software/nginx-1.15.12/sbin/nginx -V

step8 查驗執行狀態

X 參考文獻