Nginx Install Windows Service

less than 1 minute read

  • 目标:Nginx 设置成 service,系统开机自启动 *

  • 工具:Wrapper 开源项目的地址是:https://github.com/kohsuke/winsw *

STEP 1 下载Wrapper到nginx目录,更改原exe文件名称为nginx-service.exe

STEP 2 创建#同名#配置文件nginx-service.xml

<?xml version="1.0" encoding="UTF-8" ?>
<service>
  <id>nginx</id>
  <name>Nginx Media Service</name>
  <description>Nginx Based Media Streaming Server</description>
  <executable>nginx.exe</executable>
  <logpath>./logs</logpath>
  <logmode>roll</logmode>  
  <stopexecutable>nginx.exe</stopexecutable>
  <stopargument>-s</stopargument>
  <stopargument>stop</stopargument>
</service>

XML文件的详细配置教程见官方文档 xmlConfigFile.md

STEP 3 以管理员身份运行命令行工具CMD

    nginx-service.exe install

STEP 4 启动,在CMD输入启动命令,或者在系统services.msc图形界面启动

    nginx-service.exe start

该命令可使用 start | stop | install | uninstall 等,对应启动、停止、安装、卸载等

Leave a Comment