下載windows版nginx (http://nginx.org/download/nginx-1.10.0.zip),以後解壓到須要放置的位置(D:\xampp\nginx)nginx
須要藉助"Windows Service Wrapper"小工具,項目地址: https://github.com/kohsuke/winswgit
下載地址: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/1.18/winsw-1.18-bin.exegithub
下載該工具後,將其放在 Nginx安裝目錄下,並重命名爲nginx-service.exe,建立配置文件nginx-service.xml(名字要和工具名同樣),windows
建立nginx-service.exe.config(爲支持NET 4.0 runtime,默認只支持NET 2.0 runtime)瀏覽器
文件結構以下:app
nginx-service.xml 內容以下:ide
<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服務spa
D:\xampp\nginx\nginx-service.exe install
以後就能夠在Windows服務面板中啓動服務了3d
瀏覽器中就能夠正常訪問了