Windows下Nginx開機啟動


我們可以借助Windows Service Wrapper小工具【需要.net 4.0環境】,將Nginx轉換為Windows服務,這樣就可以在開機時自動啟動Nginx了。

 

 

下載后將該工具放入Nginx的安裝目錄下,並且將其重命名為 nginx-service.exe ,在該目錄下新建 nginx-service.xml 文件,寫入配置信息,配置好了之后就可以通過這個將Nginx注冊為Windows服務。

 
<!-- nginx-service.xml -->
<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <logpath>D:web\nginx\</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <executable>D:web\nginx\nginx.exe</executable>
    <stopexecutable>D:web\nginx\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