一、下載nginx地址:http:///en/download.html (穩(wěn)定版)
解壓到相應(yīng)的磁盤,本文是:E:\nginx\nginx-1.18.0
二、添加服務(wù)需要借助"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的內(nèi)容如下:
<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內(nèi)容如下:
<configuration> <startup> <supportedRuntime version="v2.0.50727" /> <supportedRuntime version="v4.0" /> </startup> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration> 最終目錄結(jié)構(gòu)如下:
最后用cmd命令進(jìn)入到nginx目錄安裝服務(wù)
卸載服務(wù)命令: sc delete 服務(wù)名
|
|