Windows 添加nginx到服務


一、下載nginx

地址:http://nginx.org/en/download.html   (穩定版)

 

 解壓到相應的磁盤,本文是:E:\nginx\nginx-1.18.0

 

二、添加服務

需要借助"Windows Service Wrapper"小工具,下載地址: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/
本文選擇:http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/2.9.0/winsw-2.9.0-bin.exe
下載后放在nginx目錄下,並修改名字為nginx-service.exe
創建配置文件nginx-service.exe.config 和 nginx-service.xml
 
nginx-service.xml的內容如下:
<service>
  <id>nginx</id>
  <name>Nginx Service</name>
  <description>High Performance Nginx Service</description>
  <logpath>E:\nginx\nginx-1.18.0\logs</logpath>
  <log mode="roll-by-size">
    <sizeThreshold>10240</sizeThreshold>
    <keepFiles>8</keepFiles>
  </log>
  <executable>E:\nginx\nginx-1.18.0\nginx.exe</executable>
  <startarguments>-p E:\nginx\nginx-1.18.0</startarguments>
  <stopexecutable>E:\nginx\nginx-1.18.0\nginx.exe</stopexecutable>
  <stoparguments>-p E:\nginx\nginx-1.18.0 -s stop</stoparguments>
</service>

 

nginx-service.exe.config內容如下:

<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727" />
    <supportedRuntime version="v4.0" />
  </startup>
  <runtime>
    <generatePublisherEvidence enabled="false"/> 
  </runtime>
</configuration>
 
最終目錄結構如下:

 

 

 

最后用cmd命令進入到nginx目錄安裝服務

 

 

卸載服務命令: sc  delete  服務名

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM