日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Windows中將Nginx添加為服務的問題_nginx

作者:錦鯉兒 ? 更新時間: 2022-04-23 編程語言

前言:在使用LeafLet寫離線地圖時,需要將Nginx作為LeafLet的代理,實現內網訪問外網地圖瓦片,下面是將Nginx添加為Windows服務。

1、下載安裝Nginx

官網:http://nginx.org/en/download.html

注意:我是將Nginx安裝到了D盤,所以后面的文件修改時注意自己的路徑問題。

2、添加服務

nginx-service.xml、cmd-restart-nginx.bat、cmd-start-nginx.bat、cmd-stop-nginx.bat
nginx-service.xml內容:

<service>
    <id>nginx180</id>
    <name>Nginx Service 1.8.0</name>
    <description>High Performance Nginx Service</description>
    <logpath>D:\nginx-1.18.0\logs</logpath>
    <log mode="roll-by-size">
        <sizeThreshold>10240</sizeThreshold>
        <keepFiles>8</keepFiles>
    </log>
	<!--
    OPTION: stopparentprocessfirst
    If set, WinSW will terminate the parent process before stopping the children.
    Default value: false
  -->
	<stopparentprocessfirst>true</stopparentprocessfirst>
    <executable>D:\nginx-1.18.0\nginx.exe</executable>
    <startarguments>-p D:\nginx-1.18.0</startarguments>
    <stopexecutable>D:\nginx-1.18.0\nginx.exe -s stop</stopexecutable>
	<stoparguments>-p D:\nginx-1.18.0</stoparguments>
</service>

cmd-restart-nginx.bat內容:

cd D:\nginx-1.18.0
nginx-service.exe stop > nul
taskkill /f /t /im nginx.exe
nginx-service.exe start > nul
pause > nul

cmd-start-nginx.bat文件內容:

cd D:\nginx-1.18.0
nginx-service.exe start >nul
pause > nul

cmd-stop-nginx.bat文件內容:

cd D:\nginx-1.18.0
nginx-service.exe stop > nul
taskkill /f /t /im nginx.exe
pause > nul

3、安裝Nginx為Windows服務

進入Nginx的安裝路徑

D:\nginx-1.18.0 >nginx-service.exe install

4、啟動Nginx服務

控制面板–>管理工具–>服務–>找到Nginx Service 1.8.0服務–>啟動

現在已經將Nginx添加為Windows服務了,可以自行測試。需要源文件的小伙伴可以私信我呀~

原文鏈接:https://blog.csdn.net/qq_45701130/article/details/122980051

欄目分類
最近更新