首頁  >  文章  >  運維  >  centos6.4下nginx1.12.1安裝的方法

centos6.4下nginx1.12.1安裝的方法

WBOY
WBOY轉載
2023-05-13 20:34:151552瀏覽

安裝所需環境

1. gcc 安裝

安裝nginx 需要先將官網下載的原始碼進行編譯,編譯依賴gcc 環境,如果沒有gcc 環境,則需要安裝:

yum install gcc-c++

2. pcre pcre-devel 安裝

pcre(perl compatible regular expressions)是一個perl函式庫,包含perl 相容的正規表示式函式庫。 nginx 的 http 模組使用 pcre 來解析正規表示式,所以需要在 linux 上安裝 pcre 函式庫,pcre-devel 是使用 pcre 開發的二次開發函式庫。 nginx也需要此程式庫。指令:

yum install -y pcre pcre-devel

3. zlib 安裝

zlib 函式庫提供了許多種壓縮和解壓縮的方式, nginx 使用zlib 對http 套件的內容進行gzip ,所以需要在centos 上安裝zlib 函式庫。

yum install -y zlib zlib-devel

4. openssl 安裝

#openssl 是一個強大的安全通訊端層密碼庫,囊括主要的密碼演算法、常用的金鑰和證書封裝管理功能及ssl 協議,並提供豐富的應用程式供測試或其它目的使用。

nginx 不僅支援 http 協議,還支援 https(即在ssl協定上傳輸http),所以需要在 centos 安裝 openssl 函式庫。

yum install -y openssl openssl-devel

安裝

1.nginx網址

2.使用wget指令下載

#wget -c https://nginx.org/download/nginx-1.12.1.tar.gz

centos6.4下nginx1.12.1安裝的方法

3.解壓縮

#
#tar -zxvf nginx-1.12.1.tar.gz
#cd nginx-1.12.1

centos6.4下nginx1.12.1安裝的方法

4.設定

#./configure

centos6.4下nginx1.12.1安裝的方法

5.安裝

#make

centos6.4下nginx1.12.1安裝的方法

#make install

找出安裝路徑:

#whereis nginx

啟動、停止nginx

#cd /usr/local/nginx/sbin/
./nginx 
./nginx -s stop
./nginx -s quit
./nginx -s reload

./nginx -s quit:此方式停止步驟是待nginx進程處理任務完畢進行停止。
./nginx -s stop:此方式相當於先查出nginx進程id再使用kill指令強制殺掉進程。

查詢nginx進程:

#ps aux|grep nginx

啟動nginx,在瀏覽器中輸入localhost

centos6.4下nginx1.12.1安裝的方法

以上是centos6.4下nginx1.12.1安裝的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除