windows下nginx以服務自啟動

來源:互聯網
上載者:User

標籤:名稱   oss   stop   程式   代碼   服務   localhost   內容   我的電腦   

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

windows下nginx以服務自啟動

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.