Windows下nginx设置开机自启动

时间:2023-03-09 17:02:26
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>

完成后的文件目录

Windows下nginx设置开机自启动

  1. 管理员权限 打开 cmd

Windows下nginx设置开机自启动

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

Windows下nginx设置开机自启动