Nginx(二) Nginx基本安裝

2022-05-18 22:34:31 字數 2793 閱讀 7507

1.安裝gcc gcc-c++

$ yum

install -y gcc

gcc-c++

2.安裝wget(如未安裝,請先安裝)

$ yum -y install

wget

3.安裝pcre庫

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

4.安裝openssl庫

openssl 是乙個強大的安全套接字層密碼庫,囊括主要的密碼演算法、常用的金鑰和證書封裝管理功能及 ssl 協議,並提供豐富的應用程式供測試或其它目的使用。nginx 不僅支援 http 協議,還支援 https(即在ssl協議上傳輸http)

5.安裝zlib庫

zlib 庫提供了很多種壓縮和解壓縮的方式, nginx 使用 zlib 對 http 包的內容進行 gzip

6.安裝nginx

7.檢測是否安裝成功

$ cd  /usr/local/nginx/sbin

$ ./nginx -t

1.顯示幫助資訊

$ /usr/local/nginx/sbin/nginx -h

幫助資訊如下:

options:

-?,-h : this help (顯示幫助資訊)

-v : show version and exit (列印nginx版本,編譯資訊等)

-v : show version and configure options then

exit (列印nginx版本,編譯資訊等)

-t : test configuration and exit (檢測語法)

-q : suppress non-error messages during configuration testing

#傳送訊號(立刻停止stop、優雅停止quit、過載配置檔案reload、重新開始記日誌reopen)

-s signal : send signal to a master process: stop, quit, reopen, reload

-p prefix : set prefix path (default: /usr/local/nginx/) (指定執行目錄)

-c filename : set configuration file (default: conf/nginx.conf)

-g directives : set global directives out of configuration file

2.啟動nginx

$ /usr/local/nginx/sbin/nginx

3.檢視程序

$ 

ps -aux | grep

'nginx

'

4.停止 nginx

$ /usr/local/nginx/sbin/nginx -s quit    #傳送訊號方式 優雅停止quit或$ 

/usr/local/nginx/sbin/nginx -s stop #傳送訊號方式 立刻停止stop

5.nginx 過載配置

$ /usr/local/nginx/sbin/nginx -s reload  #傳送訊號方式 立刻停止stop

Nginx 基本安裝

1.安裝編譯工具及庫檔案yum y install make zlib zlib devel gcc c libtool openssl openssl devel2.安裝pcre pcre的作用是讓nginx支援rewrite功能。cd opt wget解壓安裝包 tar zxvf pcre 8....

Nginx 二 nginx的安裝

使用命令 tar zxvf pcre 8.37.tar.gz 進入pcre目錄 cd pcre 8.37 執行命令 configure 掃瞄依賴建立依賴 make 安裝 make install 檢視版本 pcre config version 成功 8.37 為版本號 執行命令 yum y ins...

nginx 二 nginx的安裝

把原始碼解壓縮之後,在終端裡執行如下命令 configure make make install 預設情況下,nginx 會被安裝在 usr local nginx。通過設定編譯選項,你可以改變這個設定 乙個寫好了的編譯選項 nginx的使用比較簡單,就是幾條命令。常用到的命令如下 nginx s ...