在Windows平台上安装Nginx并设置开机自动启动服务
一、下载安装
到Nginx官网下载并安装

二、安装系统服务,让开机自动运行
1、需要借助"Windows Service Wrapper"小工具,将下载的winsw-1.18-bin.exe放在 Nginx安装目录下,并重命名为nginx-service.exe
2、创建nginx-service.exe.config,内容如下:
<configuration> <startup> <supportedRuntime version="v2.0.50727" /> <supportedRuntime version="v4.0" /> </startup> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration>
3、创建配置文件nginx-service.xml,内容如下:
<service> <id>nginx</id> <name>Nginx Service</name> <description>High Performance Nginx Service</description> <logpath>D:\nginx-1.14.2\logs</logpath> <log mode="roll-by-size"> <sizeThreshold>10240</sizeThreshold> <keepFiles>8</keepFiles> </log> <executable>D:\nginx-1.14.2\nginx.exe</executable> <startarguments>-p D:\nginx-1.14.2</startarguments> <stopexecutable>D:\nginx-1.14.2\nginx.exe</stopexecutable> <stoparguments>-p D:\nginx-1.14.2 -s stop</stoparguments> </service>
4、在cmd管理员方式中运行如下命令安装windows服务
D:\nginx-1.14.2\nginx-service.exe install