学习日志-运维01,window服务器上nginx开机自启

1.下载winsw工具

首先下载winsw工具
http://repo.jenkins-ci.org/re…

将winsw工具移动到nginx的安装目录,并将winsw工具改名为
nginx-service.exe

2.添加配置文件

然后在安装目录下新建文件
nginx-service.xml
nginx-service.exe.config

我的nginx的安装目录为C:\develop\nginx-1.12.2

此时的目录结构如图所示

《学习日志-运维01,window服务器上nginx开机自启》

nginx-service.xml文件内容

<service>
  <id>nginx</id>
  <name>nginx</name>
  <description>nginx</description>
  <env name="path" value="D:\nginx-1.15.9\nginx-1.15.9"/>
  <executable>C:/develop/nginx-1.12.2/nginx.exe</executable>
  <arguments>-p C:/develop/nginx-1.12.2</arguments>
  <logpath>C:/develop/nginx-1.12.2/logs/</logpath>
  <logmode>roll</logmode>
</service>

nginx-service.exe.config文件内容

<configuration>   
    <startup>     
        <supportedRuntime version="v2.0.50727" />     
        <supportedRuntime version="v4.0" />   
    </startup>   
    <runtime>     
        <generatePublisherEvidence enabled="false"/>    
    </runtime> 
</configuration>

注意相应的目录路径需要以实际路径为准, 下同

3.安装服务

以管理员打开cmd, 输入
C:\develop\nginx-1.12.2\nginx-service.exe install,没报错即为正常开启

4.查看服务

打开
运行(win+R),输入service.msc,然后找到nginx的项,即为成功开启服务,如图

《学习日志-运维01,window服务器上nginx开机自启》

    原文作者:lethe
    原文地址: https://segmentfault.com/a/1190000019807987
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞