13 - Windows Nginx

最後更新: 2020-06-16

 


Show Info

 

-v            : show version and exit

-V            : show version and configure options then exit

C:\nginx\nginx-1.19.0>nginx.exe -v

nginx version: nginx/1.19.0

C:\nginx\nginx-1.19.0>nginx.exe -V

nginx version: nginx/1.19.0
built by cl 16.00.40219.01 for 80x86
built with OpenSSL 1.1.1g  21 Apr 2020
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug
...

 


Install

 

cd c:\

unzip nginx-1.19.0.zip

cd nginx-1.19.0

Start

start nginx

tasklist /fi "imagename eq nginx.exe"

Signal

nginx -s stop        # fast shutdown

nginx -s quit        # graceful shutdown

nginx -s reload     # changing configuration,

                           # starting new worker processes with a new configuration,

                          # graceful shutdown of old worker processes

nginx -s reopen    # re-opening log files

 


Install As Service

 

https://datahunter.org/nssm

 


logrotate.bat

 

@echo off

:: logrotate.bat

SET NGINX_PATH=C:\nginx\nginx-1.19.0
SET PSEXEC_PATH=C:\nginx\psexec\PsExec.exe

SET DATE=%date%
SET DAY=%DATE:~0,2%
SET MONTH=%DATE:~3,2%
SET YEAR=%DATE:~6,4%
SET DATE_FRM=%YEAR%-%MONTH%-%DAY%

CD /D %NGINX_PATH%

move logs\access.log  logs\access_%DATE_FRM%.log
move logs\error.log   logs\error_%DATE_FRM%.log

%PSEXEC_PATH% -s %NGINX_PATH%\nginx.exe -p %NGINX_PATH% -s reopen

More Info

https://datahunter.org/pstools#PsExec