1、下載工具
下載地址:https://github.com/winsw/winsw/releases,如下載WinSW.NET4.exe
2、註冊服務
以nginx註冊爲本地服務進行說明。將下載後的WinSW.NET4.exe放至nginx安裝目錄,如下:
同時,編寫與WinSW.NET4同名的xml文件,放至相同目錄。WinSW.NET4.xml內容如下:
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>nginx1140</id>
<!-- Display name of the service -->
<name>nginx-1.14.0</name>
<!-- Service description -->
<description>NGINX is the popular and high‑performance web server used at millions of websites worldwide.</description>
<!-- Path to the executable, which should be started -->
<executable>D:\appdata\nginx-1.14.0\nginx.exe</executable>
</service>
在命令窗口執行:WinSW.NET4.exe install
3、服務驗證
註冊完成後,可在服務中查看:
4、其他命令
啓動服務:WinSW.NET4.exe start
關閉服務:WinSW.NET4.exe stop
重啓服務:WinSW.NET4.exe restart
卸載服務:WinSW.NET4.exe uninstall