windows設置nginx開機啓動

很多開發者在開發的時候或者其他一些條件限制,不得不使用windows環境,很多服務器上用到的軟件,在windows使用並不好用,比如nginx,在window上設置開機啓動就不是很方便。下面分享一種windows上設置軟件設置開機啓動的方式,包括不僅限於nginx。

  1. 下載WinSW(https://github.com/winsw/winsw/releases),這裏選擇的是WinSW-x64.exe,配置xml文件:全部sample-allOptions.xml和最小sample-minimal.xml;
  2. 下載並解壓nginx(https://nginx.org/en/download.html);
  3. 編寫nginx_service.xml,並將文件放到nginx.exe目錄下,將WinSW-x64.exe放到nginx.exe目錄下,並重命名爲nginx_service.exe,其中”%BASE%“表示當前目錄,xml文件參數說明在sample-allOptions.xml或sample-minimal.xml中有說明;
<service>
    <id>nginx1.24.0</id>
    <name>nginx1.24.0</name>
    <description>nginx server</description>
    <logpath>%BASE%\logs</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <arguments></arguments>
    <startmode>Automatic</startmode>
    <executable>%BASE%\nginx.exe</executable>
    <stopexecutable>%BASE%\nginx.exe -s stop</stopexecutable>
</service>
  1. 安裝服務:打開命令行窗口,進入到nginx.exe目錄下,運行命令nginx_service.exe install
  2. 相關命令。
nginx_service.exe install #安裝服務
nginx_service.exe uninstall#卸載服務
nginx_service.exe start #啓動服務
nginx_service.exe stop #停止服務
nginx_service.exe restart #重啓服務
nginx_service.exe status #查看狀態
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章