windows下nginx以服務自啟動


1.下載最新版的 Windows Service Wrapper 程序

    https://github.com/kohsuke/winsw/releases

2.可以修改它的名字,例如:myapp.exe 將重命名后的 myapp.exe 復制到 nginx 的安裝目錄

3. 在同一個nginx目錄下創建一個Windows Service Wrapper的XML配置文件,名稱必須與第一步重命名時使用的名稱一致(比如我這里是 "myapp.xml")

myapp.xml的文件內容如下:

復制代碼

<configuration>

  <!-- ID of the service. It should be unique accross the Windows system-->
  <id>nginx</id>

  <!-- Display name of the service -->
  <name>Nginx Service 1.12.2</name>

  <!-- Service description -->
  <description>High Performance Nginx Service</description>

  <executable>C:\nginx\nginx.exe</executable>

</configuration>

復制代碼

4,命令行下執行以下命令,以便將其安裝成Windows服務。

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe install

 

至此,完工,確認一下:我的電腦 右鍵 -> 管理 -> 服務 -> 是否有了個 nginx 呢?啟動起來,

在瀏覽器中 訪問 http://localhost 確認一下,再 停止服務,再訪問一下  http://localhost 確認一下。 

補充:
Windows Servcie Wrapper的命令格式如下:
 
# 安裝服務

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe install

 # 卸載服務

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe uninstall

 # 啟動服務

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe start

 # 停止服務

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe stop


免責聲明!

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



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