Windows下Nginx 開機自動啟動


下載  https://github.com/kohsuke/winsw/releases 下的這個文件  WinSW.NET4.exe 放在Nginx的安裝目錄下,並且將其重命名為 nginx-service.exe 

 

在該目錄下新建 nginx-service.xml 文件,寫入配置信息,配置好了之后就可以通過這個將Nginx注冊為Windows服務。

<!-- nginx-service.xml -->
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:nginx-1.14.0\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:nginx-1.14.0\nginx.exe</executable>
<stopexecutable>D:nginx-1.14.0\nginx.exe -s stop</stopexecutable>
</service>

服務命令
以上內容配置好了之后,在nginx安裝目錄下以管理員運行命令:.\nginx-service.exe install 就成功將其注冊為Windows服務了,然后運行 .\nginx-service.exe start 啟動服務。這時我們可以在Windows任務管理器的服務中查看該是否成功啟動。

注:

nginx-service.exe install 命令可注冊對應的系統服務
nginx-service.exe uninstall 命令可刪除對應的系統服務
nginx-service.exe stop 命令可停止對應的系統服務
nginx-service.exe start 命令可啟動對應的系統服務

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM