註:
1. 僅在Windows 7環境使用過,日期為2015-8-11,其他環境僅供參考。
2. 僅提供最簡單的設定
快速安裝與設定
nginx.conf
的server區塊: <code>server { # 替换为需要的端口 listen 80<span>;</span> server_name localhost<span>;</span> # 替换为需要的目录 root D:/Projects/nginx-html<span>;</span> index index.html index.htm index.php<span>;</span> location ~ \.php$ { include fastcgi.conf<span>;</span> # 连接到本机 PHP FastCGI Server 开启的端口 fastcgi_pass 127.0.0.1:9001<span>;</span> } }</code>
nginx
與php-cgi
所在的目錄加入Path環境變數nginx
<code>php<span>-cgi</span><span>-b</span><span>127.0</span><span>.0</span><span>.1</span>:<span>9001</span></code>
<code><span><?php</span><span>echo</span><span>"<h1>PHP works!</h1>"</span>;</code>
http://localhost:80/index.php
),並看到「PHP works!」說明成功了!
<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false"><code>@echo off
echo Starting php-cgi <span>...</span>
RunHiddenConsole php-cgi -b <span>127.0</span><span>.0</span><span>.1</span>:<span>9001</span>
echo Starting nginx <span>...</span>
c:
cd C:\Program Files\nginx-<span>1.9</span><span>.3</span>
RunHiddenConsole nginx
pause</code></pre><div class="contentsignin">登入後複製</div></div>
<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false"><code>@echo off
echo Reloading Nginx <span>...</span>
c:
cd C:\Program Files\nginx-<span>1.9</span><span>.3</span>
nginx -s reload
pause</code></pre><div class="contentsignin">登入後複製</div></div>
nginx-quit
即可快速啟動、重新啟動、關閉Nginx服務及php-cgi
2. Windows下Nginx+PHP5的安裝與設定方法
版權聲明:本文為部落客原創文章,轉載請註明出處。雖然我覺得沒什麼好起來的東西。 。 。