为nginx建立windows服务自启动

一、下载最新版的 Windows Service Wrapper 程序,好比我下载的名称是 "winsw-1.9-bin.exe",
而后,把它命名成你想要的名字(好比: "mynginx.exe",固然,你也能够不更名)nginx

二、把下载的文件(winsw-1.9-bin.exe)复制到nginx目录(D:\nginx-1.12.2)app

三、nginx目录下建立一个同名的Windows Service Wrapper的XML配置文件(winsw-1.9-bin.xml)spa

文件内容以下:命令行

<service>
  <id>nginx</id>
  <name>Nginx Service</name>
  <description>High Performance Nginx Service</description>
  <logpath>D:\nginx-1.12.2\logs</logpath>
  <log mode="roll-by-size">
    <sizeThreshold>10240</sizeThreshold>
    <keepFiles>8</keepFiles>
  </log>
  <executable>D:\nginx-1.12.2\nginx.exe</executable>
  <startarguments>-p D:\nginx-1.12.2</startarguments>
  <stopexecutable>D:\nginx-1.12.2\nginx.exe</stopexecutable>
  <stoparguments>-p D:\nginx-1.12.2\ -s stop</stoparguments>
</service>

说明:code

<name>Nginx Service</name>        #这是服务里面名字
<description>High Performance Nginx Service</description>   #这里是对服务的描述

 

四、命令行执行安装命令orm

Windows Servcie Wrapper的命令格式以下:xml

#安装服务

CMD:\> winsw-1.9-bin.exe install

#卸载服务

CMD:\> winsw-1.9-bin.exe uninstall

#启动服务

CMD:\> winsw-1.9-bin.exe start

#中止服务

CMD:\> winsw-1.9-bin.exe stop

#附个当时安装1.8版本时的图片blog

相关文章
相关标签/搜索