下载winsw
https://github.com/winsw/winsw/releases
将winsw可执行程序复制到nginx安装目录下,并重命名为nginx-service
新建名为nginx-service.xml的文件(注:文件名必须与可执行文件名相同)
并编辑如下,其中name为 服务名,executable为可执行程序路径,logpath为程序运行日志路径
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>G:\nginx-1.14.2\nginx.exe</executable>
<logpath>G:\nginx-1.14.2\testlog\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-p G:\nginx-1.14.2</startargument>
<stopargument>-p G:\nginx-1.14.2 -s stop</stopargument>
</service>
在nginx安装目录下运行cmd(快捷方式:shift + 鼠标右键),运行命令:nginx-service.exe install
注:nginx-service.exe uninstall命令可删除对应的系统服务
nginx-service.exe stop命令可停止对应的系统服务
nginx-service.exe start命令可启动对应的系统服务
启动