Nginx番外篇:Windows下Nginx 开机自动启动

下载  https://github.com/kohsuke/winsw/releases/tag/winsw-v2.3.0 下的这个文件  WinSW.NET4.exe 放在Nginx的安装目录下,并且将其重命名为 nginx-service.exe 

在该目录下新建 nginx-service.xml 文件,写入配置信息,配置好了之后就可以通过这个将Nginx注册为Windows服务。

<!-- nginx-service.xml -->
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>c: ginx-1.16.1</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>c: ginx-1.16.1 ginx.exe</executable>
<stopexecutable>c: ginx-1.16.1 ginx.exe -s stop</stopexecutable>
</service>

服务命令
以上内容配置好了之后,在nginx安装目录下以管理员运行命令:nginx-service.exe install 就成功将其注册为Windows服务了,然后运行 nginx-service.exe start 启动服务。这时我们可以在Windows任务管理器的服务中查看该是否成功启动。

注:

nginx-service.exe install 命令可注册对应的系统服务
nginx-service.exe uninstall 命令可删除对应的系统服务
nginx-service.exe stop 命令可停止对应的系统服务
nginx-service.exe start 命令可启动对应的系统服务

原文地址:https://www.cnblogs.com/flysem/p/12468463.html