我的網誌清單

2011年12月2日 星期五

在 Windows Server 2008 R2、Windows Server 2003 及 Windows 2000 Server 上使用 IIS 伺服器解譯 PHP 動態網頁


   Windows Server 2008 R2 上使用 IIS 伺服器解譯 PHP 動態網頁





 功能說明:



1.   所有 Redhat Fedora Linux 作業系統的使用者都知道在Fedora 之中內建 PHP 動態網頁伺服器。其實,你也能選擇讓 PHP Server Windows 平台例如:Windows Server 2008 R2Windows 7 Professional上執行,安裝程式的下載網址是 http://windows.php.net 。其他作業系統      SolarisMac OS X OS/2AS/400Novell NetwareRISC OSSGI IRIX 6.5.x 的作業系統上,也能執行 PHP動態網頁伺服器。請參考官方網站 http://www.php.net



2.   從另一個角度來看,Internet Information Services (IIS) 7.0  或是說 Windows Server 2008 R2 上可以執行的腳本語言不只是 ASP.NET ASP,也可以同時執行 PHP 語法。


腳本語言

公司

作業系統

網頁伺服器

(html 伺服器)

PHP 伺服器

(物件伺服器)

MySQL 伺服器

(SQL 伺服器)

PHP Script

Redhat

Fedora Linux

Apache Server

PHP Server for Linux

MySQL Server for Linux

PHP Script

Microsoft

Windows Server 2008 R2

IIS 7.0

PHP Server for Windows

MySQL Server for Windows

ASP.Net

Microsoft

Windows Server 2008 R2

IIS 7.0

.Net Framework 4.0

Microsoft SQL Server 2008 R2 Express

ASP

Microsoft

Windows Server 2008 R2

IIS 7.0


Microsoft SQL Server 2008 R2 Express











安裝與設定:

若要讓 PHP Windows Server 2008 R2 作業系統上執行,你必須安裝與設定下列軟體元件:





第一章     安裝 Internet Information Service 7.0

1、 安裝 IIS (Internet Information Service) 7.0 的方式為:

Windows Server 2008 R2作業系統安裝完成後所出現的歡迎頁』設定

Server Manager Add Roles Add Roles WizardNext Add Roles → select Web ServerIIS Nextseveral “next” Install】。









第二章     安裝與設定PHP Server 5.3.6

1、 下載網址: http://windows.php.net/download/

VC9 x86 Thread SafeInstaller檔名php-5.3.6-Win32-VC9-x86.msi



2、 安裝過程選擇 IIS FastCGI】;勾選安裝元件 Extras】【PHP Manual】。

若在安裝 PHP Server 過程中安裝元件 Extras】【PHP Manual】,則你在設定 PHP Server 時就可以參考路徑:【PHP Manual Installation and Configuration Installation on Windows systems Microsoft IIS 7.0 and later】。



3、 設定 php.ini(檔案路徑:“C:\Program Files (x86)\PHP\php.ini”)檔案的 4 個項目:

fastcgi.impersonate = 1

fastcgi.logging = 0

cgi.fix_pathinfo=1

cgi.force_redirect = 0



4、 設定 IIS Manager

【控制台】 【系統管理工具】 Internet Information ServicesIIS)管理員 (滑鼠雙擊)Default Web Site 【處理常式對應】【新增模組對應】

要求路徑 (P):              *.php

模組 (M):                    FastCgiModule

執行檔 (選擇性) (E): Executable: C:\[Path to PHP installation]\php-cgi.exe

名稱 (N):                     PHP_via_FastCGI



5、 測試網頁:

將下列網頁內容儲存在路徑 “C:\inetpub\wwwroot”,檔名命名為 “info.php”。若下列指令可以執行,並且可以列出大部分設定的參數值,則表示 PHP Server 設定成功。





<?php

phpinfo();

?>









第三章     安裝與設定 MySQL Community Server 5.5.15



1、 下載網址http://www.mysql.com/downloads/ ,選擇 MySQL Community Server 5.5.15 版本。檔名:mysql-5.5.15-win32.msi      mysql-5.5.15-winx64.msi

安裝過程需要輸入密碼兩次:這份文件使用的是 “HkEVEkdqjUBS”,若全部測試成功,請再自行更換。





2、 建立資料庫中的資料:

將下列內容儲存為檔名 create_table.sql,路徑為“C:\inetpub\wwwroot”。執行時,先輸入密碼,再將下列內容貼到【MySQL 5.5 Command Line Client】就會開始執行。





use test;



create table table_01 (

        name                   char(30),

        area_code          char(10),

        phone_number          char(30)

);



insert into table_01 (name, area_code, phone_number) values ('Elvis','059','345179');

insert into table_01 (name, area_code, phone_number) values ('Adrian','037','580670');

insert into table_01 (name, area_code, phone_number) values ('Joshua','048','457106');

insert into table_01 (name, area_code, phone_number) values ('Denny','072','475603');

insert into table_01 (name, area_code, phone_number) values ('Reed','061','303857');



select * from table_01;





3、 測試網頁:

將下列內容儲存為檔名 test_01.php,路徑為“C:\inetpub\wwwroot”。執行時若能看到一個表格, 表示 PHP Server 可以正常從 MySQL Server 查詢出資料。也就是MySQL Server PHP Server兩者安裝成功。





<?php



        $host = "localhost";

        $user="root";

        $password="HkEVEkdqjUBS";



$stmt="select name, area_code, phone_number from table_01";

mysql_connect($host, $user, $password);

$result=mysql_db_query("test", $stmt);



?>





<br>

<table border>

<caption><h2>Table_Title</h2></caption>

<tr><th> name <th> area_code <th> phone_number





<?php

while ($row=mysql_fetch_object($result))

{

echo ("<tr><td>"); echo $row->name; echo("<td align=center>"); echo $row->area_code; echo ("<td align=center>"); echo $row->phone_number;

}

?>





<?php

echo("</table>");

mysql_free_result($result);

?>











第四章     其他設定

1、  Server Manager 歡迎頁』會在每次 Windows Server 2008 R2 開機時出現,關掉它的方法是勾選Server Manager】中的【Do not show me the console at logon】。

















Copyright © 此文件歡迎翻譯成外國語文,只是作者仍持有此文件之著作權。並且在翻譯成外國語文之後,若是為了保有本文文意或推廣之目的,作者仍享有提出修改及用詞之權利。若原文作者未提出修改之要求時,以能夠表達技術上及操作上之正確性為優先考量。















   Windows Server 2003 上使用 IIS 伺服器解譯 PHP 動態網頁





 功能說明:



3.   所有 Redhat Fedora Linux 作業系統的使用者都知道在Fedora 之中內建 PHP 動態網頁伺服器。其實,你也能選擇讓 PHP Server Windows 平台例如:Windows Server 2008 R2Windows Server 2003Windows 7 Professional上執行,安裝程式的下載網址是 http://windows.php.net 。其他作業系統      SolarisMac OS X OS/2AS/400Novell NetwareRISC OSSGI IRIX 6.5.x 的作業系統上,也能執行 PHP動態網頁伺服器。請參考官方網站 http://www.php.net



4.   從另一個角度來看,Internet Information Services (IIS) 6.0  或是說 Windows Server 2003 上可以執行的腳本語言不只是 ASP.NET ASP,也可以同時執行 PHP 網頁。


腳本語言

公司

作業系統

網頁伺服器

(html 伺服器)

PHP 伺服器

(物件伺服器)

MySQL 伺服器

(SQL 伺服器)

PHP Script

Redhat

Fedora Linux

Apache Server

PHP Server for Linux

MySQL Server for Linux

PHP Script

Microsoft

Windows Server 2003

IIS 6.0

PHP Server for Windows

MySQL Server for Windows

ASP.Net

Microsoft

Windows Server 2003

IIS 6.0

.Net Framework 4.0

Microsoft SQL Server 2000 MSDE

ASP

Microsoft

Windows Server 2003

IIS 6.0


Microsoft SQL Server 2000 MSDE













安裝與設定:

若要讓 PHP Windows Server 2003 作業系統上執行,你必須安裝與設定下列軟體元件:





第一章     安裝 Internet Information Service 6.0

2、 安裝 IIS (Internet Information Service) 6.0 的方式為:

【控制台】 【新增或移除程式】 【新增/移除 Windows 元件】 Application Server(詳細資料)_【網際網路資訊服務 (IIS)(詳細資料)_【全球資訊網服務】(詳細資料)_ 勾選【全球資訊網服務】。







第二章     安裝與設定PHP Server 5.2.17

6、 下載網址: http://windows.php.net/download/

VC6 x86 Thread SafeZip檔名php-5.2.17-Win32-VC6-x86.zip



7、 安裝 PHP Server

(1)    在系統磁碟 C: 的根目錄底下建立一個資料夾,命名為 C:\php5\

(2)    將檔名為 php-5.2.17-Win32-VC6-x86.zip 的檔案解壓縮後,複製到 C:\php5 目錄底下。



8、 設定 PHP Server

(1)    將位於 C:\php5 目錄底下,檔名為 php.ini-recommended 的檔案複製到 C:\Windows\ 目錄底下,檔名更改為 php.ini

(2)    將位於 C:\php5 目錄底下,檔名為 libmysql.dll  的檔案複製到 C:\Windows\system32 的目錄底下。



9、 C:\Windows 目錄底下, 修改檔名 php.ini 的參數:

(1)    設定延伸檔 *.dll 的目錄到 C:\php5\ext\ :

extension_dir = "C:\php5\ext\"

(2)    移除 mysql 延伸檔那一行的標記符號 “;” :

extension=php_mysql.dll

(3)    你可以在此時將電腦重新開機,或者在完成所有的設定之後再重新開機。



10、          設定網際網路資訊服務 ( IIS) 管理員:

(1)    【控制台】 【系統管理工具】 【網際網路資訊服務 (IIS) 管理員 (滑鼠左鍵)展開【網站】【+  (滑鼠右鍵)【預設的網站】(滑鼠左鍵)【內容】選擇【主目錄】標籤頁 【設定】【新增】→ a. 【執行檔】_【瀏覽】_ “C:\php5\php5isapi.dll” b. 【副檔名】_“.php”

(2)    【控制台】 【系統管理工具】 【網際網路資訊服務 (IIS) 管理員 (滑鼠右鍵)【網頁服務延伸】 (滑鼠左鍵)【新增網頁服務延伸】→ a. 【延伸名稱】_ “PHP”b. 【需要的檔案】_【新增】_【瀏覽】_ “C:\php5\php5isapi.dll” c. 勾選【設定延伸狀態成允許】。



11、          測試網頁:

將下列網頁內容儲存在路徑 “C:\inetpub\wwwroot”,檔名命名為 “info.php”。若下列指令可以執行,並且可以列出大部分設定的參數值,則表示 PHP Server 設定成功。





<?php

phpinfo();

?>











第三章     安裝與設定 MySQL Community Server 5.5.15



4、 下載網址http://www.mysql.com/downloads/ ,選擇 MySQL Community Server 5.5.15 版本。檔名:mysql-5.5.15-win32.msi      mysql-5.5.15-winx64.msi

安裝過程需要輸入密碼兩次:這份文件使用的是 “HkEVEkdqjUBS”,若全部測試成功,請再自行更換。





5、 建立資料庫中的資料:

將下列內容儲存為檔名 create_table.sql,路徑為“C:\inetpub\wwwroot”。執行時,先輸入密碼,再將下列內容貼到【MySQL 5.5 Command Line Client】就會開始執行。





use test;



create table table_01 (

        name                   char(30),

        area_code          char(10),

        phone_number          char(30)

);



insert into table_01 (name, area_code, phone_number) values ('Elvis','059','345179');

insert into table_01 (name, area_code, phone_number) values ('Adrian','037','580670');

insert into table_01 (name, area_code, phone_number) values ('Joshua','048','457106');

insert into table_01 (name, area_code, phone_number) values ('Denny','072','475603');

insert into table_01 (name, area_code, phone_number) values ('Reed','061','303857');



select * from table_01;





6、 測試網頁:

將下列內容儲存為檔名 test_01.php,路徑為“C:\inetpub\wwwroot”。執行時若能看到一個表格, 表示 PHP Server 可以正常從 MySQL Server 查詢出資料。也就是MySQL Server PHP Server兩者安裝成功。





<?php



        $host = "localhost";

        $user="root";

        $password="HkEVEkdqjUBS";



$stmt="select name, area_code, phone_number from table_01";

mysql_connect($host, $user, $password);

$result=mysql_db_query("test", $stmt);



?>





<br>

<table border>

<caption><h2>Table_Title</h2></caption>

<tr><th> name <th> area_code <th> phone_number





<?php

while ($row=mysql_fetch_object($result))

{

echo ("<tr><td>"); echo $row->name; echo("<td align=center>"); echo $row->area_code; echo ("<td align=center>"); echo $row->phone_number;

}

?>





<?php

echo("</table>");

mysql_free_result($result);

?>







第四章     安裝與設定 FastCGI 1.5



1、 下載網址:http://www.iis.net/download/FastCGI  

FastCGI 1.5 for IIS 6 and 5.1x86/x64檔名fcgisetup_1.5_rtw_x86.msi



2、 C:\Windows 目錄底下, 修改檔名 php.ini 的參數:

cgi.force_redirect = 0

cgi.fix_pathinfo=1

fastcgi.impersonate = 1

fastcgi.logging = 0



3、 開啟【命令提示字元】,執行下列項目



cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\php5\php-cgi.exe"



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -ActivityTimeout:90



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -RequestTimeout:90



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHPRC:"C:\php5\"











Copyright © 此文件歡迎翻譯成外國語文,只是作者仍持有此文件之著作權。並且在翻譯成外國語文之後,若是為了保有本文文意或推廣之目的,作者仍享有提出修改及用詞之權利。若原文作者未提出修改之要求時,以能夠表達技術上及操作上之正確性為優先考量。















   Windows 2000 Server 上使用 IIS 伺服器解譯 PHP 動態網頁





 功能說明:



            所有 Redhat Fedora Linux 作業系統的使用者都知道在Fedora 之中內建 PHP 動態網頁伺服器。其實,你也能選擇讓 PHP Server Windows 平台例如:Windows Server 2008 R2Windows Server 2003Windows 7 ProfessionalWindows XP ProfessionalWindows 2000 Server上執行,安裝程式的下載網址是 http://windows.php.net 。其他作業系統      SolarisMac OS X OS/2AS/400Novell NetwareRISC OSSGI IRIX 6.5.x 的作業系統上,也能執行 PHP動態網頁伺服器。請參考官方網站 http://www.php.net



            從另一個角度來看,Internet Information Services (IIS) 5.0  或是說 Windows 2000 Server 上可以執行的腳本語言不只是 ASP.NET ASP,也可以同時執行 PHP 網頁。


腳本語言

公司

作業系統

網頁伺服器

(html 伺服器)

PHP 伺服器

(物件伺服器)

MySQL 伺服器

(SQL 伺服器)

PHP Script

Redhat

Fedora Linux

Apache Server

PHP Server for Linux

MySQL Server for Linux

PHP Script

Microsoft

Windows 2000 Server

IIS 5.0

PHP Server for Windows

MySQL Server for Windows

ASP.Net

Microsoft

Windows 2000 Server

IIS 5.0

.Net Framework 4.0

Microsoft SQL Server 2000 MSDE

ASP

Microsoft

Windows 2000 Server

IIS 5.0


Microsoft SQL Server 2000 MSDE











安裝與設定:

若要讓 PHP Windows 2000 Server 作業系統上執行,你必須安裝與設定下列軟體元件:





第一章     安裝 Service Pack 4 及所有的安全性更新

          作業系統安裝完成後,安裝下列修正檔:Windows 2000 Service Pack 4Windows 2000 SP4 更新彙總套件1 Internet Explorer 6 Service Pack 1

          (在此處為選擇性,不是必須的)執行 Windows Update 兩次或三次。







第二章     安裝 Internet Information Service 5.0

            安裝 IIS (Internet Information Service) 5.0 的方式為:

【設定】 →【控制台】 →【新增/移除程式】 【新增/移除 Windows 元件】 →【Internet Information Services (IIS)(詳細資料)_World Wide Web 伺服器】。







第三章     安裝與設定PHP Server 5.2.17

    下載網址: http://windows.php.net/download/

VC6 x86 Thread Safe】→ Zip檔名php-5.2.17-Win32-VC6-x86.zip



            安裝 PHP Server

            在系統磁碟 C: 的根目錄底下建立一個資料夾,命名為 C:\php5\

            將檔名為 php-5.2.17-Win32-VC6-x86.zip 的檔案解壓縮後,複製到 C:\php5 目錄底下。



        設定 PHP Server

            將位於 C:\php5 目錄底下,檔名為 php.ini-recommended 的檔案複製到 C:\WINNT\ 目錄底下,檔名更改為 php.ini

            將位於 C:\php5 目錄底下,檔名為 libmysql.dll  的檔案複製到 C:\WINNT\system32 的目錄底下。



            C:\WINNT 目錄底下, 修改檔名 php.ini 的參數:

            設定延伸檔 *.dll 的目錄到 C:\php5\ext\ :

extension_dir = "C:\php5\ext\"

            移除 mysql 延伸檔那一行的標記符號 ; :

extension=php_mysql.dll

            你可以在此時將電腦重新開機,或者在完成所有的設定之後再重新開機。



        設定網際網路資訊服務 ( IIS) 管理員:

【程式集】 【系統管理工具】 Internet 服務管理員】 (滑鼠左鍵)展開【主機名稱】【+  (滑鼠右鍵)【預設的 Web 站台】→ (滑鼠左鍵)【內容】→ 選擇【主目錄】標籤頁 【設定】→ 【新增】→ a. 【執行檔】_【瀏覽】_ C:\php5\php5isapi.dll b. 【副檔名】_.php”



            測試網頁:

將下列網頁內容儲存在路徑 C:\inetpub\wwwroot”,檔名命名為 info.php”。若下列指令可以執行,並且可以列出大部分設定的參數值,則表示 PHP Server 設定成功。





<?php

phpinfo();

?>







第四章     安裝與設定 MySQL Community Server 5.1.58



        下載網址【http://www.mysql.com/downloads/MySQL Community ServerLooking for previous GA versions?】,選擇 MySQL Community Server 5.1.58 Essential 版本。檔名:mysql-essential-5.1.58-win32.msi      mysql-essential-5.1.58-winx64.msi

安裝過程需要輸入密碼兩次:這份文件使用的是 “HkEVEkdqjUBS”,若全部測試成功,請再自行更換。





        建立資料庫中的資料:

將下列內容儲存為檔名 create_table.sql,路徑為“C:\inetpub\wwwroot”。執行時,先輸入密碼,再將下列內容貼到【MySQL 5.1 Command Line Client】就會開始執行。





use test;



create table table_01 (

        name                   char(30),

        area_code          char(10),

        phone_number          char(30)

);



insert into table_01 (name, area_code, phone_number) values ('Elvis','059','345179');

insert into table_01 (name, area_code, phone_number) values ('Adrian','037','580670');

insert into table_01 (name, area_code, phone_number) values ('Joshua','048','457106');

insert into table_01 (name, area_code, phone_number) values ('Denny','072','475603');

insert into table_01 (name, area_code, phone_number) values ('Reed','061','303857');



select * from table_01;





            測試網頁:

將下列內容儲存為檔名 test_01.php,路徑為“C:\inetpub\wwwroot”。執行時若能看到一個表格, 表示 PHP Server 可以正常從 MySQL Server 查詢出資料。也就是MySQL Server PHP Server兩者安裝成功。





<?php



        $host = "localhost";

        $user="root";

        $password="HkEVEkdqjUBS";



$stmt="select name, area_code, phone_number from table_01";

mysql_connect($host, $user, $password);

$result=mysql_db_query("test", $stmt);



?>





<br>

<table border>

<caption><h2>Table_Title</h2></caption>

<tr><th> name <th> area_code <th> phone_number





<?php

while ($row=mysql_fetch_object($result))

{

echo ("<tr><td>"); echo $row->name; echo("<td align=center>"); echo $row->area_code; echo ("<td align=center>"); echo $row->phone_number;

}

?>





<?php

echo("</table>");

mysql_free_result($result);

?>







第五章     安裝與設定 FastCGI 1.5



            下載網址:http://www.iis.net/download/FastCGI 

FastCGI 1.5 for IIS 6 and 5.1x86/x64檔名fcgisetup_1.5_rtw_x86.msi



            FastCGI 1.5直接安裝到 Windows 2000 Server 會不成功,因此需要先安裝到一台 Windows Server 2003 Windows XP Professional 的主機上(Windows 7 Professional 已經內建在其他目錄,因此也不會安裝成功)。再將下列檔案複製到 Windows 2000 Server 主機中的 C:\WINNT\System32\inetsrv 目錄下:

fcgiconfig.js

fcgiext.dll

fcgiext.ini

fcgilicense.rtf

fcgireadme.htm



            C:\WINNT 目錄底下, 修改檔名 php.ini 的參數:

cgi.force_redirect = 0

cgi.fix_pathinfo=1

fastcgi.impersonate = 1

fastcgi.logging = 0



            開啟【命令提示字元】,執行下列項目



cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\php5\php-cgi.exe"



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -ActivityTimeout:90



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -RequestTimeout:90



cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHPRC:"C:\php5\"











Copyright © 此文件歡迎翻譯成外國語文,只是作者仍持有此文件之著作權。並且在翻譯成外國語文之後,若是為了保有本文文意或推廣之目的,作者仍享有提出修改及用詞之權利。若原文作者未提出修改之要求時,以能夠表達技術上及操作上之正確性為優先考量。










沒有留言:

張貼留言