工具使用 Ngnix

2021-08-09 16:23:19 字數 2561 閱讀 7167

####1,centos上

安裝nginx: yum install nginx   (/etc/nginx)

解除安裝nginx:yum remove nginx

檢視nginx安裝目錄: ps -ef | grep nginx

啟動nginx: service nginx start

殺掉程序:pkill -9 nginx

####2,增加防火牆的訪問許可權:

-a input -p tcp --dport 80 -j accept -a output -p tcp --sport 80 -j accept

####3,反向**,虛擬網域名稱的配置 :

編輯 sudo vim /usr/local/nginx/conf/nginx.conf

####4,mac上nginx的安裝:

(1),brew install nginx

安裝完以後,可以在終端輸出的資訊裡看到一些配置路徑:

/usr/local/etc/nginx/nginx.conf (配置檔案路徑)

/usr/local/var/www (伺服器預設路徑)

/usr/local/cellar/nginx/1.12.0 (安裝路徑)(我安裝的是1.12.0,具體參照自己安裝的版本)

(2),啟動

進入安裝路徑   cd  /usr/local/cellar/nginx/1.12.0/bin

啟動 sudo ./nginx

重啟 sudo ./nginx -s reload

判斷配置檔案是否正確 sudo ./nginx -t

nginx -s reload|reopen|stop|quit

(3),訪問

localhost:8080

(4),修改nginx配置

開啟 nginx.config 檔案

/usr/local/etc/nginx/nginx.conf

在該檔案底部引入vhost下所有conf配置檔案

include vhost/*.conf

在vhost下建立mytest.conf

touch mytest.conf

重啟nginx瀏覽器訪問即可。

(5),mytest.conf具體內容:

server 

location /

location @router

}

(6),修改nginx監聽埠為3000避免與tomcat衝突。 nginx.conf檔案:

include vhost/*.conf; }

(7),修改nginx監聽埠為3000避免與tomcat衝突。 nginx.conf.default同上(6)

(8) , nginx請求**到tomcat配置;修改nginx.conf

server 

error_page 404 /404.html;

location = /40x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html

}

####5,附錄:nginx的ssl證書配置: vi /etc/nginx/conf.d/ssl.conf

#server configuration

server

location @router

error_page 404 /404.html;

location = /40x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html

}

image服務配置:vi /etc/nginx/vhost/image.conf

server 

}

埠**的配置(監聽nginx的https埠443,把其中訪問**到tomcat的8443埠上去:

server 

}

ngnix 安裝筆記

yum update 更新系統類庫 yum install gcc 安裝ngnix 依賴包 安裝pcre庫 cd usr local wget tar zxvf pcre 8.40.tar.gz cd pcre 8.40 configure make make install 安裝zlib庫 cd ...

Ngnix 流量拷貝

在需要真實的流量做旁路測試的時候,我們就可以使用 nginx 來做流量的拷貝 nginx 自1.13.4 版本開始,自帶乙個 ngx http mirror module,使用起來非常簡單,只要在需要 mirror 的 location 處新增 mirror 關鍵字就行 copy 123 4567 ...

刪除Ngnix 日誌

刪除ngnix日誌的指令碼 bin bash 初始化 logs path pwd logs yesterday date d yesterday y m d 按天切割日誌 mv access log access log 向 nginx 主程序傳送 usr1 訊號,重新開啟日誌檔案,否則會繼續往mv...