、下载最新版的 Windows Service Wrapper 程序,下载地址:
http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/
比如我下载的名称是 "winsw-2.2.0-bin.exe",可以把它命名成你想要的名字(比如: "mynginx.exe",当然,你也可以不改名)
2、把下载的文件(winsw-2.2.0-bin.exe)复制到nginx目录里面
3、nginx目录下创建一个同名的Windows Service Wrapper的XML配置文件(winsw-2.2.0-bin.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>D:\software\nginx-1.17.0\nginx.exe</executable>
<logpath>D:\software\nginx-1.17.0\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-p D:\software\nginx-1.17.0</startargument>
<stopargument>-p D:\software\nginx-1.17.0 -s stop</stopargument>
</service>
4、命令行执行安装命令
Windows Servcie Wrapper的命令格式如下:
#安装服务
CMD:\> winsw-2.2.0-bin.exe install
#卸载服务
CMD:\> winsw-2.2.0-bin.exe uninstall
#启动服务
CMD:\> winsw-2.2.0-bin.exe start
#停止服务
CMD:\> winsw-2.2.0-bin.exe stop
5、install过程出现问题,winsw-2.2.0-bin.wrapper.log报错,
2019-06-14 17:10:21,058 DEBUG - Starting ServiceWrapper in the CLI mode
2019-06-14 17:10:21,693 INFO - Installing the service with id 'nginx'
2019-06-14 17:10:21,706 FATAL - WMI Operation failure: AccessDenied
WMI.WmiException: AccessDenied
将cmd工具,改成 以管理员身份运行 就可以了。