一、下載nginx地址:http:///en/download.html (穩(wěn)定版)
解壓到相應的磁盤,本文是:E:\nginx\nginx-1.18.0
二、添加服務需要借助"Windows Service Wrapper"小工具,下載地址: http://repo./releases/com/sun/winsw/winsw/
本文選擇:http://repo./releases/com/sun/winsw/winsw/2.9.0/winsw-2.9.0-bin.exe
下載后放在nginx目錄下,并修改名字為nginx-service.exe
創(chuàng)建配置文件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 服務名
|
|
|