windows下nginx开机自动启动
- 下载 https://github.com/winsw/winsw/releases 下 WinSW.NET4.exe 到 D:\nginx 目录下
- 修改WinSW.NET4.exe名称为nginx-service.exe
- D:\nginx目录下新建 nginx-service.xml 文件
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:nginx\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:nginx\nginx.exe</executable>
<stopexecutable>D:nginx\nginx.exe -s stop</stopexecutable>
</service>
- 在nginx安装目录下以管理员运行命令
D:\nginx> nginx-service.exe install
D:\nginx> nginx-service.exe uninstall
D:\nginx> nginx-service.exe stop
D:\nginx> nginx-service.exe start
Linux下nginx开机自启
> nginx -t