下载windows版nginx (),之后解压到需要安排的位置(D:\xampp\nginx)
将Nginx设置为Windows处事需要借助"Windows Service Wrapper"小工具,项目地点: https://github.com/kohsuke/winsw
下载地点:
下载该工具后,将其放在 Nginx安置目录下,并重定名为nginx-service.exe,创建配置文件nginx-service.xml(名字要和工具名一样),
创建nginx-service.exe.config(为撑持NET 4.0 runtime,,默认只撑持NET 2.0 runtime)
文件布局如下:
nginx-service.xml 内容如下:
<service> <id>nginx</id> <name>Nginx Service</name> <description>High Performance Nginx Service</description> <logpath>D:\xampp\nginx\logs</logpath> <log mode="roll-by-size"> <sizeThreshold>10240</sizeThreshold> <keepFiles>8</keepFiles> </log> <executable>D:\xampp\nginx\nginx.exe</executable> <startarguments>-p D:\xampp\nginx</startarguments> <stopexecutable>D:\xampp\nginx\nginx.exe</stopexecutable> <stoparguments>-p D:\xampp\nginx -s stop</stoparguments> </service>
nginx-service.exe.config 内容如下:
<configuration> <startup> <supportedRuntime version="v2.0.50727" /> <supportedRuntime version="v4.0" /> </startup> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration>
在cmd中运行如下命令安置windows处事
D:\xampp\nginx\nginx-service.exe install
之后就可以在Windows处事面板中启动处事了
浏览器中就可以正常访谒了