1.下载nginx
下载windows版的Nginx安装包,进入类似下图页面,选择合适版本下载。下载后解压。
2.下载Windows Service Wrapper工具
选择合适版本下载,该工具可设置nginx为windows服务。地址
nginx-service.exe.config内容如下:
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
nginx-service.xml内容如下:
<service>
<id>nginx</id>
<name>Nginx Service</name>
<description>High Performance Nginx Service</description>
<logpath>C:\Program Files\Nginx\logs</logpath>
<log mode="roll-by-size">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>8</keepFiles>
</log>
<executable>C:\Program Files\Nginx\nginx.exe</executable>
<startarguments>-p C:\Program Files\Nginx</startarguments>
<stopexecutable>C:\Program Files\Nginx\nginx.exe</stopexecutable>
<stoparguments>-p C:\Program Files\Nginx -s stop</stoparguments>
</service>
3.安装nginx服务
进入Nginx安装目录,然后执行命令
nginx-service.exe install