window 怎么樣讓nginx開機自啟動


安裝Nginx

下載windows版nginx (http://nginx.org/download/nginx-1.10.0.zip),之后解壓到需要放置的位置(D:\xampp\nginx)

將Nginx設置為Windows服務

需要借助"Windows Service Wrapper"小工具,項目地址: https://github.com/kohsuke/winsw

下載地址: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/1.18/winsw-1.18-bin.exe

下載該工具后,將其放在 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服務面板中啟動服務了

瀏覽器中就可以正常訪問了

網址:http://blog.csdn.net/weixin_37288522/article/details/70576409


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM