Windows下实现Nginx开机自启动

一、开机自启

1.右击“新建”->点击“文本文档”->双击打开”文本文档”复制粘贴一下内容:


<service>
    <id>nginxid>   
    <name>Nginx Servicename>   
    <description>High Performance Nginx Servicedescription>
    env>
    <executable>nginx.exeexecutable>
    <executable>nginx.exe -s stopexecutable>
    <logpath>D:Nginx-auto\nginx-1.14.0.57-A\logs\logpath>
    <log mode="roll-by-size">     
        <sizeThreshold>10240sizeThreshold>     
        <keepFiles>8keepFiles>   
    log>
service>

Ctrl + s保存->右击“文本文档”->重命名” nginx-service.xml”

2.右击“新建”->点击“文本文档”->双击打开”文本文档”复制粘贴一下内容:

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

Ctrl + s保存->右击“文本文档”->重命名” nginx-service.exe.config”

3.下载“WinSW.NETCore.x64.exe”->重命名“nginx-service.exe”:

Win + R->cmd回车->nginx-service.exe install

注:执行完后即可在“服务”列表看到Nginx Service服务 点击启动并设置自动即可。
(设置开机自启的同时reload将无法使用,只能执行ln-stop.bat关闭服务)

你可能感兴趣的:(Windows,server,2008,运维,服务器,nginx)