nginx安裝 附件

2021-07-25 00:26:21 字數 3601 閱讀 8043

什麼是nginx?

nginx 作為 負載均衡 伺服器: 

nginx 既可以在內部直接支援 rails 和 php 程式對外進行服務,也可以支援作為 http **伺服器對外進行服務。 nginx 採用 c 進行編寫, 不論是系統資源開銷還是 cpu 使用效率都比 perlbal 要好很多。作為郵件**伺服器: 

nginx 同時也是乙個非常優秀的郵件**伺服器(最早開發這個產品的目的之一也是作為郵件**伺服器), last.fm 描述了成功並且美妙的使用經驗。nginx 是乙個安裝非常簡單,配置檔案非常簡潔(還能夠支援perl語法), bugs非常少的伺服器: nginx 啟動特別容易,並且幾乎可以做到 7*24 不間斷執行,即使執行數個月也不需要重新啟動。 你還能夠不間斷服務的情況下進行軟體版本的公升級。

nginx的安裝

模組依賴性nginx需要依賴下面3個包

依賴包安裝順序依次為:openssl、zlib、pcre, 然後安裝nginx包.

**教程

openssl-fips-2.0.12.tar.gz

zlib-1.2.8.tar.gz

pcre-8.38.tar.gz

nginx-1.2.9.tar.gz

第二步:依次安裝openssl-fips-2.0.12.tar.gz, zlib-1.2.8.tar.gz, pcre-8.38.tar.gz, nginx-1.2.9.tar.gz

1.安裝openssl-fips-2.0.12.tar.gz

[root@localhost mrms]# tar -zxvf openssl-fips-2.0.12.tar.gz 

[root@localhost mrms]# cd openssl-fips-2.0.12

[root@localhost openssl-fips-2.0.12]# ./config

[root@localhost openssl-fips-2.0.12]# make

[root@localhost openssl-fips-2.0.12]# make install

2.安裝zlib-1.2.8.tar.gz

[root@localhost mrms]# tar -zxvf zlib-1.2.8.tar.gz

[root@localhost mrms]# cd zlib-1.2.8

[root@localhost zlib-1.2.8]# ./configure

[root@localhost zlib-1.2.8]# make

[root@localhost zlib-1.2.8]# make install

3.安裝pcre-8.83.tar.gz

[root@localhost mrms]# tar -zxvf pcre-8.38.tar.gz

[root@localhost mrms]# cd pcre-8.38

[root@localhost pcre-8.38]# ./configure

[root@localhost pcre-8.38]# make
[root@localhost pcre-8.38]# make install
4.安裝 nginx-1.2.9.tar.gz

[root@localhost mrms]# tar -zxvf nginx-1.2.9.tar.gz 

[root@localhost mrms]# cd nginx-1.2.9

[root@localhost nginx-1.2.9]# ./configure --with-pcre=/opt/nginx/pcre-8.38 --with-zlib=/opt/nginx/zlib-1.2.8 --with-openssl=../openssl-fips-2.0.12

[root@localhost nginx-1.2.9]# make

[root@localhost nginx-1.2.9]# make install

至此nginx的安裝完成!

第三步:檢測是否安裝成功

[root@localhost nginx-1.2.6]# cd  /usr/local/nginx/sbin

[root@localhost sbin]# ./nginx -t

出現如下所示提示,表示安裝成功

啟動nginx

[root@localhost sbin]# ./nginx
檢視埠

[root@localhost sbin]# netstat -ntlp
結果如下

推薦教程:

一、啟動  

cd usr/local/nginx/sbin

./nginx

二、重啟

更改配置重啟nginx  

kill -hup 主程序號或程序號檔案路徑

或者使用

cd /usr/local/nginx/sbin

./nginx -s reload

判斷配置檔案是否正確 

nginx -t -c /usr/local/nginx/conf/nginx.conf

或者cd /usr/local/nginx/sbin

./nginx -t

-c 為 nginx 指定乙個配置檔案,來代替預設的。

-t 不執行,而僅僅測試配置檔案。nginx 將檢查配置檔案的語法的正確性,並嘗試開啟配置檔案中所引用到的檔案。

-v 顯示 nginx 的版本。

-v 顯示 nginx 的版本,編譯器版本和配置引數。

不啟動,僅測試配置檔案:/usr/bin/nginx -t -c ~/mynginx.conf

三、關閉

查詢nginx主程序號

ps -ef | grep nginx

從容停止   kill -quit 主程序號

快速停止   kill -term 主程序號

強制停止   kill -9 nginx

若nginx.conf配置了pid檔案路徑,如果沒有,則在logs目錄下

kill -訊號型別 '/usr/local/nginx/logs/nginx.pid'

四、公升級

1、先用新程式替換舊程式檔案

2、kill -usr2 舊版程式的主程序號或者程序檔名

此時舊的nginx主程序會把自己的程序檔案改名為.oldbin,然後執行新版nginx,此時新舊版本同時執行

3、kill -winch 舊版本主程序號

4、不過載配置啟動新/舊工作程序

kill -hup 舊/新版本主程序號

從容關閉舊/新程序

kill -quit 舊/新程序號

快速關閉舊/新程序

kill -term 舊/新程序號

附件一 安裝RESTClient

第一步 首先打 狐瀏覽器,點選右上角的 三 圖示按鈕。第二步 點選 出來乙個提示框,我們選擇 add ons 因為我的是中文的選擇這個圖示 第三步 此時會進入火狐的應用商店,我們在右上角的搜尋框中輸入 restclient 回車搜尋。第四步 因為我已經安裝了restclient,此時再搜尋就不會出來...

nginx安裝(yum安裝)

安裝先決條件 yum install y yum utils要設定yum儲存庫,請建立 etc yum.repos.d nginx.repo 包含以下內容的檔案 true預設情況下,使用穩定的nginx軟體包的儲存庫。如果要使用主線nginx軟體包,請執行以下命令 yum config manage...

Nginx學習 一 Nginx安裝

4.結語 最近專案不太忙,阿里雲伺服器也快過期了,所以趁著這個空閒,好好利用伺服器資源,練練手,寫寫部落格。宣告 以下所有操作和截圖都來自於本人阿里雲伺服器例項,操作邏輯和nginx概述借鑑於其他nginx系列部落格。作業系統 centos7.2 64位 nginx是乙個免費的 開源的 高效能的we...