当前位置:首页 > 科技新闻 > Windows编程 > 正文

Window下将nginx配置为开机自动启动
2021-10-15 15:04:26

本人配置:

需要下载个程序。地址:https://github.com/kohsuke/winsw/releases

向下寻找下图显示的位置  下载对应文件

 

 

 一定要按照自己的系统下载对应文件。

然后把下载的文件移动到nginx的根目录,然后重命名为nginxservice.exe。

再新建一个nginxservice.xml文件。

nginxservice.xml文件内容为:

<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <logpath>D:
ginx-1.20.1</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <executable>D:
ginx-1.20.1
ginx.exe</executable>
    <stopexecutable>D:
ginx-1.20.1
ginx.exe -s stop</stopexecutable>
</service>

  我的nginx根目录在D盘  需要自己去修改根目录位置  看下图:

 

 然后cmd(管理员模式)进入nginx根目录 运行 nginxservice.exe install

或者powerShell(管理员模式)进入nginx根目录 运行 . ginxservice.exe install

成功后去看系统服务是否有nginx 服务   服务名称可以修改 name 命名为自己想要的格式  本人没做修改。

成功后如下图:启动服务并设置自动启动

 

  

 

本文摘自 :https://www.cnblogs.com/