nginx windows服务

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> 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。