一、下载nginx
nginx下载地址http://nginx.org/en/download.html
二、下载Windows Service Wrapper工具
下载地址:https://github.com/winsw/winsw/releases/tag/v2.11.0
三、配置
将下载好的工具放到nginx根目录,可以改个名字nginx-service.exe
在nginx根目录创建xml配置文件
<service>
<!-- 唯一服务ID-->
<id>nginx</id>
<!-- 显示服务的名称 -->
<name>Nginx Service</name>
<!-- 服务描述 -->
<description>Nginx服务</description>
<!-- 日志路径 -->
<logpath>自己的电脑日志路径</logpath>
<!-- 日志模式 -->
<logmode>roll</logmode>
<!-- 可执行文件的命令 -->
<executable>nginx磁盘路径\nginx.exe</executable>
<!-- 停止可执行文件的命令 -->
<stopexecutable>nginx磁盘路径\nginx.exe -s stop</stopexecutable>
</service>
三、启动
nginx根目录下打开dos命令窗口
nginx-service.exe install