Making Sense of The Infinite

Unlocking Infinite Possibilities Through Curiosity

Creating a Simple Dashboard Panel for Managing an Nginx Server on Windows

Simple Dashboard Panel for Managing an Nginx Server on Windows

Creating a Simple Dashboard Panel for Managing an Nginx Server on Windows

You should modify the path of your NGINX installation in the script by specifying the exact path to the NGINX executable. This is especially useful on Windows, where NGINX is typically not added to the system PATH by default.

Save the code below to a file named: NginxDashboardPanel.bat

@echo off
rem Nginx Dashboard Panel
 
echo ==================begin========================
 
cls 
::ngxin Disk Path
set NGINX_PATH=D:
 
::nginx Work Path
set NGINX_DIR=D:\AppServer\nginx\
color 0a 
TITLE Nginx Dashboard Panel
 
CLS 
 
echo. 
echo. ***** Nginx Dashboard Panel *****
echo. 
 
:MENU 
 
echo. ***** Nginx Process List ****** 
::tasklist|findstr /i "nginx.exe"
tasklist /fi "imagename eq nginx.exe"
 
echo. 
 
    if ERRORLEVEL 1 (
        echo nginx.exe NOT FOUND
    ) else (
        echo nginx.exe is OK
    )
 
echo. 
::*************************************************************************************************************
echo. 
	echo.  [1] Start Nginx  
	echo.  [2] Stop Nginx  
	echo.  [3] Restart Nginx 
	echo.  [4] Refresh Dashboard Panel  
	echo.  [5] Reload Nginx Config Files
	echo.  [6] Check Nginx Config Files
	echo.  [7] Check Nginx Version
	echo.  [0] Exit 
echo. 
 
echo.SWITCH :
set /p ID=
	IF "%id%"=="1" GOTO start 
	IF "%id%"=="2" GOTO stop 
	IF "%id%"=="3" GOTO restart 
	IF "%id%"=="4" GOTO MENU
	IF "%id%"=="5" GOTO reloadConf 
	IF "%id%"=="6" GOTO checkConf 
	IF "%id%"=="7" GOTO showVersion 
	IF "%id%"=="0" EXIT
PAUSE 
 
::*************************************************************************************************************

:start 
	call :startNginx
	GOTO MENU
 
:stop 
	call :shutdownNginx
	GOTO MENU
 
:restart 
	call :shutdownNginx
	call :startNginx
	GOTO MENU
 
:checkConf 
	call :checkConfNginx
	GOTO MENU
 
:reloadConf 
    call :checkConfNginx
	call :reloadConfNginx
	GOTO MENU
	
:showVersion 
    call :showVersionNginx
	GOTO MENU	
	
	
::*************************************************************************************
::Underlaying
::*************************************************************************************
:shutdownNginx
	echo. 
	echo.Stop Nginx...... 
	taskkill /F /IM nginx.exe > nul
	echo.OK,Close All Nginx Process
	goto :eof
 
:startNginx
	echo. 
	echo.Start Nginx...... 
	IF NOT EXIST "%NGINX_DIR%nginx.exe" (
        echo "%NGINX_DIR%nginx.exe" NOT EXSIT
        goto :eof
     )
 
	%NGINX_PATH% 
	cd "%NGINX_DIR%" 
 
	IF EXIST "%NGINX_DIR%nginx.exe" (
		echo "start '' nginx.exe"
		start "" nginx.exe
	)
	echo.OK
	goto :eof
	
 
:checkConfNginx
	echo. 
	echo.Check Nginx Config Files...... 
	IF NOT EXIST "%NGINX_DIR%nginx.exe" (
        echo "%NGINX_DIR%nginx.exe" NOT EXSIT
        goto :eof
     )
 
	%NGINX_PATH% 
	cd "%NGINX_DIR%" 
	nginx -t -c conf/nginx.conf
 
	goto :eof
	
:reloadConfNginx
	echo. 
	echo.Reload Nginx Config Files...... 
	IF NOT EXIST "%NGINX_DIR%nginx.exe" (
        echo "%NGINX_DIR%nginx.exe" NOT EXSIT
        goto :eof
     )
 
	%NGINX_PATH% 
	cd "%NGINX_DIR%" 
	nginx -s reload
 
	goto :eof
	
:showVersionNginx
	echo. 
	%NGINX_PATH% 
	cd "%NGINX_DIR%" 
	nginx -V
 	goto :eof
BAT (Batchfile)

Last revised on

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *