
1、下载地址 https://github.com/winsw/winsw/releases。选择操作系统匹配的版本,例如WinSW-net461.exe,重命名为 nginx-service.exe。

2、创建配置文件 nginx-service.xml。
<!-- nginx-service.xml -->
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:\nginx\nginx-1.22.0\logs\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:\nginx\nginx-1.22.0\nginx.exe</executable>
<stopexecutable>D:\nginx\nginx-1.22.0\nginx.exe -s stop</stopexecutable>
</service>
3、nginx-service.exe install 创建服务。
注册系统服务命令: nginx-service.exe install 删除已注册的系统服务命令: nginx-service.exe uninstall 停止对应的系统服务命令: nginx-service.exe stop 启动对应的系统服务命令: nginx-service.exe start