您的位置:首页 > 运维架构 > Nginx

为nginx创建windows服务自启动

2018-02-09 16:09 399 查看
1、下载最新版的 Windows Service Wrapper 程序,比如我下载的名称是 "winsw-1.9-bin.exe",
然后,把它命名成你想要的名字(比如: "mynginx.exe",当然,你也可以不改名)

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

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

文件内容如下:

<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>

说明:

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

4、命令行执行安装命令

Windows Servcie Wrapper的命令格式如下:

#安装服务

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版本时的图片

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx 创建 windows