配置nginx並建立為windows服務 配置

2021-09-12 20:26:04 字數 2001 閱讀 1530

建立nginx-service.exe.config(為支援net 4.0 runtime,預設只支援net 2.0 runtime)

檔案結構:

nginx-service.xml 配置:

nginx

nginx service

high performance nginx service

e:\software\nginx-1.15.9\logs

10240

8 e:\software\nginx-1.15.9\nginx.exe

-p e:\software\nginx-1.15.9

e:\software\nginx-1.15.9\nginx.exe

-p e:\software\nginx-1.15.9 -s stop

nginx-service.exe.config 配置:

在cmd中執行如下命令安裝windows服務(e:\software\nginx-1.15.9\nginx-service.exe  install)

之後就可以在windows服務面板中啟動服務了

瀏覽器訪問看看

nginx按不同的目錄分發給不同的專案

啟用二級網域名稱,不同的專案分配不同的二級網域名稱

注意:這三個專案屬於不同的網域名稱,專案之間通過http訪問會存在跨域問題。

server 

location ^~ /customer

location /

在nginx.conf中的server裡面加入

location /nginx_status
配置完後重新啟動nginx後我們可以通過瀏覽器訪問 http://loclahost/nginx_status檢視,如下圖:

解析:active connconnections     //當前nginx正處理的活動連線數。

server accepts handledrequests   //總共處理了42個連線,成功建立42次握手,總共處理了146個請求。

reading     //nginx讀取到客戶端的header資訊數。

writing     //nginx返回給客戶端的header資訊數。

waiting     //開啟keep-alive的情況下,這個值等於  active-(reading +writing) ,意思就是nginx已經處理完正在等候下一次請求指令的駐留連線no2

root和alias都可以定義在location模組中,都是用來指定請求資源的真實路徑。。。

root  :真實的路徑是root指定的值加上location指定的值 。

alias  :指定的路徑是location的別名,不管location的值怎麼寫,資源的真實路徑都是 alias 指定的路徑

其他區別:

1、 alias 只能作用在location中,而root可以存在server、http和location中。

2、alias 後面必須要用 「/」 結束,否則會找不到檔案,而 root 則對 」/」 可有可無。

為nginx配置https並自簽名證書

2016年11月15日 22 30 47 閱讀數 5518 一 把證書準備好。步驟與使用openssl自簽發伺服器https證書所述大同小異。在這裡再重複一次。1 製作ca證書 ca.key ca私鑰 openssl genrsa des3 out ca.key 2048製作解密後的ca私鑰 一般無...

為nginx配置https並自簽名證書

步驟與使用openssl自簽發伺服器https證書所述大同小異。在這裡再重複一次。優化nginx效能 在http 中加入 ssl session cache shared ssl 10m ssl session timeout 10m 據官方文件所述,cache中的1m可以存放4000個sessio...

為nginx配置https並自簽名證書

一 把證書準備好。步驟與使用openssl自簽發伺服器https證書所述大同小異。在這裡再重複一次。1 製作ca證書 ca.key ca私鑰 openssl genrsa des3 out ca.key 2048 製作解密後的ca私鑰 一般無此必要 openssl rsa in ca.key out...