Nginx 安装成Windows服务

下载nginx windows版本

sc create ptNginx binpath= "%~dp0srvany.exe" displayname= "ptNginx" start= auto
(sc query ptNginx | find "ptNginx">nul && reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ptNginx\Parameters" /v "Application" /d "%~dp0nginx.exe")
(sc query ptNginx | find "ptNginx">nul && reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ptNginx\Parameters" /v "AppParameters" /d "")
(sc query ptNginx | find "ptNginx">nul && reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ptNginx\Parameters" /v "AppDirectory" /d "%~dp0")
(sc query ptNginx | find "ptNginx">nul && net start ptNginx)
EXIT

start nginx

start nginx

Run the tasklist command-line utility to see nginx processes:

tasklist /fi "imagename eq nginx.exe"

nginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands:

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

你可能感兴趣的:(Nginx 安装成Windows服务)