Win10将nginx添加到【服务】

Windows下将nginx配置为【服务】

下载windows版nginx

到官网中下载nginx,http://nginx.org/en/download.html
选择windows版就行,本文安装目录 D:\tools\nginx-1.17.10

借助Windows Service Wrapper小程序

  1. 添加服务 需要借助**“Windows Service Wrapper”**小工具下载地址:https://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/2.9.0/winsw-2.9.0-bin.exe(本文使用)
  2. 将“winsw-2.9.0-bin.exe”改名为 nginx-service.exe
  3. 添加配置文件:
    nginx-service.xml
<?xml version="1.0" encoding="UTF-8" ?>
<service>
    <id>nginx</id>
    <name>Nginx Service 1.8.0</name>
    <description>High Performance Nginx Service</description>
    <logpath>D:\tools\nginx-1.17.10\logs</logpath>
    <log mode="roll-by-size">
        <sizeThreshold>10240</sizeThreshold>
        <keepFiles>8</keepFiles>
    </log>
	<!--
    OPTION: stopparentprocessfirst
    If set, WinSW will terminate the parent process before stopping the children.
    Default value: false
  -->
	<stopparentprocessfirst>true</stopparentprocessfirst>
    <executable>D:\tools\nginx-1.17.10\nginx.exe</executable>
    <startarguments>-p D:\tools\nginx-1.17.10</startarguments>
    <stopexecutable>D:\tools\nginx-1.17.10\nginx.exe -s stop</stopexecutable>
	<stoparguments>-p D:\tools\nginx-1.17.10</stoparguments>
</service>

nginx-service.exe.config


  1. 执行添加nginx为服务
D:
cd tools\nginx-1.17.10
nginx-service.exe install

安装完成:
在这里插入图片描述

*卸载服务命令: sc delete 服务名 *

注:查阅相关资料时,发现网上,很多文档都是互抄,缺少 第 1、2步导致安装不上,信息缺失,特此记录下。若不是被环境限制,也不会考虑用windows安装nginx ^ - ^ - -

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值