標籤:名稱 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以服務自啟動