NGINX开机自动启动

   借助Windows Service Wrapper工具,将Nginx转换为Windows服务,在服务中心配置自启动,从而在开机时windows自行启动Nginx服务。

1、自启动工具下载 工具下载地址:https://github.com/winsw/winsw/releases
 2、自启动工具安装 
  下载后将该工具放入Nginx的安装目录下,并且将其重命名为nginx-service.exe 2)在nginx安装目录下新建服务日志文件夹server-logs文件夹,用来存放nginx服务相关日志 3)在该目录下新建 nginx-service.xml 文件,写入配置信息,配置好了之后可以将nginx注册为Windows服务 文件配置内容如下:日志文件位置 启动命令关闭命令
<!-- nginx-service.xml -->
<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <logpath>E:\nginx-1.22.0\server-logs\</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <executable>E:\nginx-1.22.0\nginx.exe</executable>
    <stopexecutable>E:\nginx-1.22.0\nginx.exe -s stop</stopexecutable>
</service>
配置完成后nginx目录:
 3、把nginx注册为windows服务  
     在nginx安装目录下以管理员运行命令:.\nginx-service.exe install 将其注册为Windows服务,检查注册结果。
     设置nginx为登录用户模式支持reload模式:
   
 
    将启动方式修改为自启动,启动nginx服务。
 
 nginx reload 参考命令:
 
nginx其他命令 注册系统服务命令 nginx-service.exe install 删除已注册的系统服务命令 nginx-service.exe uninstall 停止对应的系统服务命令 nginx-service.exe stop 启动对应的系统服务命令 nginx-service.exe start
 
posted @ 2023-09-08 17:23  沐乐  阅读(544)  评论(0)    收藏  举报