码迷,mamicode.com
首页 > Windows程序 > 详细

windows下nginx以服务自启动

时间:2018-04-24 13:56:41      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:名称   oss   stop   程序   代码   服务   localhost   内容   我的电脑   

1.下载最新版的 Windows Service Wrapper 程序

    https://github.com/kohsuke/winsw/releases

2.可以修改它的名字,例如:myapp.exe 将重命名后的 myapp.exe 复制到 nginx 的安装目录

3. 在同一个nginx目录下创建一个Windows Service Wrapper的XML配置文件,名称必须与第一步重命名时使用的名称一致(比如我这里是 "myapp.xml")

myapp.xml的文件内容如下:

技术分享图片

<configuration>

  <!-- ID of the service. It should be unique accross the Windows system-->
  <id>nginx</id>

  <!-- Display name of the service -->
  <name>Nginx Service 1.12.2</name>

  <!-- Service description -->
  <description>High Performance Nginx Service</description>

  <executable>C:\nginx\nginx.exe</executable>

</configuration>

技术分享图片

4,命令行下执行以下命令,以便将其安装成Windows服务。

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe install

 

至此,完工,确认一下:我的电脑 右键 -> 管理 -> 服务 -> 是否有了个 nginx 呢?启动起来,

在浏览器中 访问 http://localhost 确认一下,再 停止服务,再访问一下  http://localhost 确认一下。 

补充:
Windows Servcie Wrapper的命令格式如下:
 
# 安装服务

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe install

 # 卸载服务

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe uninstall

 # 启动服务

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe start

 # 停止服务

D:\NeatbeansSofts\Redis-x64-3.2.100> myapp.exe stop

windows下nginx以服务自启动

标签:名称   oss   stop   程序   代码   服务   localhost   内容   我的电脑   

原文地址:https://www.cnblogs.com/wangfeixiong/p/8929130.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!