nginx的windows版,本身并没有集成将其作为系统服务的功能。

目前可以实现这一需求的方案可以使用第三方工具kohsuke/winsw

 

使用上得注意,winsw的配置文件和执行文件必须放在同一个目录下,且文件名称必须要一致

id节点决定在服务列表中的名称,name节点决定在服务列表的描述。

 

可参考的配置内容

<service>
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>nginx</id>
  <!-- Display name of the service -->
  <name>nginx Service</name>
  <!-- Service description -->
  <description>This nginx service is a service created from a minimal configuration</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>%BASE%\nginx.exe</executable>
  <logpath>%BASE%\logs</logpath>
  <startarguments>-p %BASE%\nginx.exe</startarguments>
  <stopexecutable>%BASE%\nginx.exe</stopexecutable>
  <stoparguments>-s stop</stoparguments>
</service>