我的網誌清單

2011年12月2日 星期五

在 Windows 7 Professional 及 Windows XP Professional 上使用 IIS 伺服器解譯 PHP 動態網頁


   Windows 7 Professional 上使用 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) 6.1  或是說 Windows 7 Professional 上可以執行的腳本語言不只是 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 7 Professional

IIS 6.1

PHP Server for Windows

MySQL Server for Windows

ASP.Net

Microsoft

Windows 7 Professional

IIS 6.1

.Net Framework 4.0

Microsoft SQL Server 2008 Express

ASP

Microsoft

Windows 7 Professional

IIS 6.1


Microsoft SQL Server 2008 Express













安裝與設定:

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





第一章     安裝 Internet Information Service 6.1

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

【控制台】 【程式和功能】 【開啟或關閉 Windows 功能】 勾選【Internet Information Service】【Web 管理工具】【IIS 管理主控台】 World Wide Web 服務】 【應用程式開發功能】【CGI】。







第二章     安裝與設定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);

?>















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















   Windows XP Professional 上使用 IIS 伺服器解譯 PHP 動態網頁





 功能說明:



3.   所有 Redhat Fedora Linux 作業系統的使用者都知道在Fedora 之中內建 PHP 動態網頁伺服器。其實,你也能選擇讓 PHP Server Windows 平台例如:Windows Server 2008 R2Windows Server 2003Windows 7 ProfessionalWindows XP 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) 5.1  或是說 Windows XP Professional 上可以執行的腳本語言不只是 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 XP Professional

IIS 5.1

PHP Server for Windows

MySQL Server for Windows

ASP.Net

Microsoft

Windows XP Professional

IIS 5.1

.Net Framework 4.0

Microsoft SQL Server 2000 MSDE

ASP

Microsoft

Windows XP Professional

IIS 5.1


Microsoft SQL Server 2000 MSDE













安裝與設定:

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





第一章     安裝 Internet Information Service 5.1

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

【控制台】 【新增或移除程式】 【新增/移除 Windows 元件】 Internet Information Services (IIS)(詳細資料)_World Wide Web Service(詳細資料)_ 勾選【World Wide Web Service】。







第二章     安裝與設定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) 管理員:

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



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












沒有留言:

張貼留言