Windows下Nginx 开机自动启动

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

 

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

<!-- nginx-service.xml -->
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:nginx-1.14.0\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:nginx-1.14.0\nginx.exe</executable>
<stopexecutable>D:nginx-1.14.0\nginx.exe -s stop</stopexecutable>
</service>

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

注:url

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

spa

相关文章
相关标签/搜索