Windows下nginx设置开机自启动

第一步:下载 WinSW

https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NET4.exe 64位系统

https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NET2.exe 32位系统

第二步:配置步骤

  1. 将 WinSW.NET4.exe 复制到 x:\xxxx\nginx\目录中,修改文件名称为 nginxservice.exe 。
  2. 在 nginxservice.exe 同目录中,新建一个空的 nginxservice.xml 文件(名字要与nginxservice.exe 名字前缀保持一致,但后缀是xml) ,nginxservice.xml 的内容:
<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <logpath>D:\nginx\nginx-1.18.0</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <executable>D:\nginx\nginx-1.18.0\nginx.exe</executable>
    <stopexecutable>D:\nginx\nginx-1.18.0\nginx.exe -s stop</stopexecutable>
</service>

完成后的文件目录

  1. 用 管理员权限 打开 cmd

  1. 去服务里面启动 nginx服务

posted @ 2021-11-29 19:09  向往明天-tsingyun  阅读(399)  评论(0编辑  收藏  举报