window下的nginx是运行在console进程上的,查看nginx进程需要命令
tasklist /fi "imagename eq nginx.exe"
杀死进程可以用命令
taskkill /pid pid /f
nginx 启动命令
start nginx #相当于双击exe文件,故不需要启动参数
nginx -s stop 快速关闭
nginx -s quit 安全关闭
nginx -s reload 重新加载配置
nginx -s reopen 重新打开日志文件
想要把nginx做成windows服务,可以借助工具winsw,
GitHub:https://github.com/kohsuke/winsw,
Binaries :http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/
文档说明:https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
具体操作:
下载winsw,放到nginx根目录,改名为nginx-service.exe(名字任意),新建xml为nginx-service.xml(名字要和winsw的exe一致)
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>%BASE%/nginx.exe</executable>
<stopexecutable>%BASE%/nginx.exe -s quit</stopexecutable>
<stopparentprocessfirst>true</stopparentprocessfirst>
<depend></depend>
<logpath>%BASE%/logs</logpath>
<log mode="roll-by-time">
<pattern>yyyyMMdd</pattern>
</log>
</service>