1.安装Nginx以服务方式启动:
a.下载 instsrv.exe、srvany.exe
以管理员方式启动CMD执行以下命令:
instsrv Nginx D:\nginx\srvany.exe
b.添加注册表关键附带运行Nginx
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]
"Application"="D:\\nginx\\nginx.exe"
"AppParameters"=""
"AppDirectory"="D:\\nginx\\"
2.添加批处理文件以,Windows计划任务开始执行:
@ECHO OFF
rem 停止nginx服务
net stop nginx rem 杀掉nginx进程,因为一个服务可能启动多个nginx进程
taskkill /F /IM nginx.exe rem 产生移动日志文件命令
set "cmdstr=move D:\nginx\logs\access.log D:\nginx\logs\logbak\access%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%.log" rem 移动日志文件
call %cmdstr%" rem 启动nginx服务
net start nginx
附件下载:nginx.rar