下载winSW:https://github.com/kohsuke/winsw/releases
重命名为:server.exe
创建server.xml:
<service>
<id>nginx</id>
<name>Nginx Service</name>
<description>High Performance Nginx Service</description>
<logpath>E:\soft\nginx1.16\logs</logpath>
<log mode="roll-by-size">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>8</keepFiles>
</log>
<executable>E:\soft\nginx1.16\nginx.exe</executable>
<startarguments>-p E:\soft\nginx1.16</startarguments>
<stopexecutable>E:\soft\nginx1.16\nginx.exe</stopexecutable>
<stoparguments>-p E:\soft\nginx1.16 -s stop</stoparguments>
</service>
创建server.conf:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>

cmd下运行:
server.exe install
浏览器输入:localhost 验证
本文介绍如何使用WinSW工具将Nginx配置为Windows服务。通过下载并重命名WinSW为server.exe,创建server.xml和server.conf文件,设置Nginx的路径和参数,最终在CMD下运行安装命令,使Nginx能在Windows环境中作为服务自动启动。

1823

被折叠的 条评论
为什么被折叠?



