1.下载注册服务工具,下载地址: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/1.18/winsw-1.18-bin.exe,下载该工具后,将其放在nginx的 根目录下
2.在nignx的根目录下新建个mynginx.xml(必须和前面的mynginx.exe一致),编辑内容:
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>C:\nginx</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>C:\nginx\nginx.exe</executable>
<stopexecutable>C:\nginx\nginx.exe -s stop</stopexecutable>
</service>
stopexecutable、executable、logpath为nignx的真实路径
3.进入nginx根目录执行以下命令,注册nginx为系统服务
mynginx.exe install
启动nginx:net start nginx
停止nginx:net stop nginx
删除所有的nginx进程(可以启动多个nginx.exe)
taskkill /IM nginx.exe /F