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:\nginx-1.16.1\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>c:\nginx-1.16.1\nginx.exe</executable>
<stopexecutable>c:\nginx-1.16.1\nginx.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 命令可启动对应的系统服务

posted @ 2020-03-12 12:49  温子画  阅读(442)  评论(0编辑  收藏  举报