在 Windows 上将 nginx 注册为系统服务
使用工具
步骤
- 创建服务配置文件
nginx_service.xml
<service>
<id>nginx</id>
<name>Nginx Service</name>
<description>Nginx Service</description>
<logpath>D:\Software\nginx\logs</logpath>
<logmode>roll</logmode>
<executable>D:\Software\nginx\nginx.exe</executable>
<startarguments></startarguments>
<stoparguments>-s stop</stoparguments>
</service>- 使用 winsw 注册
.\WinSW-x64.exe install "D:\Software\nginx\nginx_service.xml"- 服务启动与停止
sc start nginx
sc stop nginx