第一步:下載 WinSW
https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NET4.exe 64位系統
https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NET2.exe 32位系統
第二步:配置步驟
- 將
WinSW.NET4.exe
復制到 x:\xxxx\nginx\
目錄中,修改文件名稱為nginxservice.exe
。 - 在
nginxservice.exe
同目錄中,新建一個空的nginxservice.xml
文件(名字要與nginxservice.exe
名字前綴保持一致,但后綴是xml) ,nginxservice.xml
的內容:
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:\nginx\nginx-1.18.0</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:\nginx\nginx-1.18.0\nginx.exe</executable>
<stopexecutable>D:\nginx\nginx-1.18.0\nginx.exe -s stop</stopexecutable>
</service>
完成后的文件目錄
- 用 管理員權限 打開 cmd
- 去服務里面啟動 nginx服務