zoukankan      html  css  js  c++  java
  • 利用WindowsServiceWrapper(WinSW)将Nginx包装为系统服务

    1. WindowsServiceWrapper(WinSW)

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

    下载地址:http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/

    介绍:
    A wrapper executable that can be used to host any executable as an Windows service, in a liberal license
    (一个可执行文件的包装器,可以托管任何可执行文件作为windows服务)

    2. 将nginx作为windows系统服务是使用nginx做为web服务器的windows系统的刚需

    好处:

    • 一方面,可以保证nginx随着系统运行而运行(比如重新启动),只需要将nginx服务设为自动运行即可,不需要手动操作
    • 另一方面,不受用户的登录或注销影响(用户注销会将当前用户运行的所有程序退出)

    3. 下载WinSw
    4. 将下载后的文件(如 winsw-2.1.2-bin.exe )拷贝至nginx根目录,将重命名为nginx-service.exe
    5. 在nginx根目录下创建 nginx-service.xml 文件,内容如下
    <?xml version="1.0" encoding="UTF-8" ?>
    
    <service>
    
     <id>Nginx</id>
    
     <name>Nginx</name>
    
     <description>本服务用于加载Nginx服务,请确保开机启动。</description>
    
     <logpath>C:
    ginxlogs</logpath>
    
     <executable>nginx.exe</executable>
    
     <stopexecutable>nginx.exe</stopexecutable>
    
     <stopargument>-s</stopargument>
    
     <stopargument>stop</stopargument>
    
     <logmode>rotate</logmode>
    
    </service>
    
    6. 做完4、5两个步骤配置就基本完成了,以下是安装及卸载的命令
    7. 打开dos命令行工具,并定位到nginx根目录
    安装
    nginx-service.exe install
    
    卸载
    nginx-service.exe uninstall
    
    8. 用命令行运行或停止nginx服务
    net start nginx
    
    net stop nginx
    
  • 相关阅读:
    一点优化小知识
    网站结构优化之一
    [JOISC 2016 Day 3] 电报
    [HDU 6157] The Karting
    [JOISC 2015 Day2] Keys
    Educational Codeforces Round 107 (Rated for Div. 2)
    [JOISC 2020 Day4] 治疗计划
    CF1131G Most Dangerous Shark
    [APIO2016] 划艇
    [ICPC World Finals 2018] 绿宝石之岛
  • 原文地址:https://www.cnblogs.com/eedc/p/12868328.html
Copyright © 2011-2022 走看看