Window下将nginx配置为开机自动启动

  1. 下载相应的.exe文件
    https://github.com/kohsuke/winsw/releases
  2. 复制到放在nginx根目录下 重命名为:nginxservice.exe
  3. 创建一个nginxservice.xml文件, 修改logpath executable stopexecutable 的绝对路径
<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <logpath>C:\opt\nginx-1.16.1</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <executable>C:\opt\nginx-1.16.1\nginx.exe</executable>
    <stopexecutable>C:\opt\nginx-1.16.1\nginx.exe -s stop</stopexecutable>
</service>
  1. 执行执行命令
nginxservice.exe install
  1. 打开服务 找到nginx 右键启动
posted @ 2022-03-11 23:16  刺头  阅读(175)  评论(0编辑  收藏  举报