Apache 2ºÍPHPÊÇ´´½¨½»»¥Ê½ÍøÕ¾µÄÁ÷ÐÐ*½°¸£¬¶øÇҳɱ¾ºÜµÍ¡£ÔÚWindowsÖа²×°Apache 2ÊÇÒ»¼þÇa¶øÒ×¾ÙµÄÊÂÇe£¬µ«ÒªÊ¹PHP 4ÓeApache 2ÅaºÏÎÞ¼aµØÔËÐУ¬¾ÍÐeÒªÒ»¶¨µÄ¼¼ÇÉ¡£
¡¡¡¡ÔÚPHP 4.3ÊÖ²aµÄWindows°²×°Ð¡½Ú£¬Ã»ÓнaÊÍÈçºÎÈÃPHPÓeApache 2ÅaºÏʹÓ㬶øÓйØApache 2°²×°µÄС½ÚȱʧÁËÄaÐeÒªµÄ´oÁ¿ÐÅÏ¢¡£ÔÚÍøÉϹ«²¼µÄÆaËu°²×°Ö¸ÄÏÖУ¬Ò²°uº¬Á˲»ÉÙ´iÎo£¬Ê¹Ò»Ð(C)°²×°ÈËÔ±Ö»ºÃ²»¶ÏÊÔÑeºÍ¸´i¡£ÀýÈ磬ÓÐÐ(C)ÈËÉoÖÁ½«PHPµÄDLLÌae»»³ÉÆaËuPHP°ae±¾µÄDLL¡£OK£¬ÎªÁ˽ÚÊ¡ÄaµÄ±¦¹oʱ¼a£¬ÎÒÃÇ×¼±¸ÁËÕaƪ×iȨÍþµÄÖ¸ÄÏÎÄÕ£¬°iÄaɨ³ýÒ»ÇгÄÕ¡£
¡¡¡¡Ê¹ÓÃÕýÈ*°ae±¾µÄWindows
¡¡¡¡Ê×ÏÈҪ˵һ˵¼aeÈÝÐÔ£ºApache 2²»ÄÜÔÚWindows 95ÉÏÔËÐУ»ÔÚWindows 98ÉÏÃaÇ¿Äܹ»ÔËÐУ¬µ«²»ÄÜ×÷Ϊ*þÎñʹÓᣴÓ4.3°ae±¾¿ªÊ¼£¬PHPÒ²²»ÔÙÖ§³ÖWindows 95¡£ËuÒÔ£¬ÄaµÄWindows²Ù×÷ϵͳ±ØÐeÊÇWindows NT¡¢2000»oÕßXP¡£
¡¡¡¡Apache 2£ºÔ´Âe»¹ÊǶþ½øÖÆ?
¡¡¡¡Èç¹uÄaÓÐVisual C++ 5.0»o¸u¸ßµÄ°ae±¾£¬»oÕß°²×°ÁËMicrosoft Visual Studio£¬ÄÇôËaÈ»¿ÉÒÔ¸u¾ÝÔ´ÂeÀ´Éu³ÉApache£¬µ«Çe¾ø¶Ô²»ÒªÕaÑu×o¡£ÔÚVisual Studio IDEÖУ¬WindowsϵÄÉu³É¹ý³Ìdz£¸´ÔÓ¡£¼´Ê¹´ÓÃuÁiÐбaÒe£¬Ò²¾ø¶Ô²»ÊÇÒ»¼þÒ×Ê¡£ËuÒÔ£¬³ýÇÄaϲ»¶´´½¨makefile£¬ñÔo×iºÃ»ñµÃÒ»ÝWindows Installer¶þ½øÖÆ*¢Ðаu£¬Ò²¾ÍÊÇÒ»¸o.msiÎļþ¡£µÈÄa¶ÔApacheÓÐÁË×a¹»¶aµÄÈÏʶ£¬ÖªµÀ×Ô¼ºÒª½øÐÐÄÄÐ(C)¶¨ÖƲÙ×÷ʱ£¬²Å¿É¿¼ÂÇÇ×ÊÖÉu³É£¨±aÒe£(C)Apache¡£
¡¡¡¡Èç¹uÒѾ°²×°ºÃ²¢ÕýÔÚÔËÐÐÀÏ°ae±¾µÄApache£¬Ê×ÏÈҪֹͣËu£¬Ð¶ÔØËu£¬È»ºo²ÅÄÜ¿ªÊ¼°²×°ÐÂ*þÎñÆ÷¡£¶a¸o°ae±¾µÄApache 2²»Äܹ²´ae¡£
¡¡¡¡Ë«»÷Apache 2 .msiÎļþ¡£Í¬ÒaÐi¿ÉÐÒeºo£¬ÕýÈÉeÖÃNetwork DomainºÍServer Name£¨Èç¹u²»´oËa½«Apache°²×°µ½Ô¶³Ì¼ÆËa»u£¬ÄÇôÉeÖÃlocalhost¾Í¿ÉÒÔÁË£(C)£¬ÔÚAdministrator's Email AddressÇøÓoÊaÈeÄaµÄµç×ÓÓʼþµØÖ£¬±£³Ö¶Ë¿Ú80/þÎñÑ¡Ïiµ¥Ñ¡Å¥µÄÑ¡ÖÐ״̬¡£ÔÚÏÂÒ»¸o¶Ô»°¿oÖÐÈç¹uÑ¡ÔñTypical°²×°£¬¿ÉÒÔ¿iËٵػñµÃÒ»¸oÄÜʵ¼Ê¹¤×÷µÄþÎñÆ÷»*¾³¡£
¡¡¡¡°²×°Ìaʾ
¡¡¡¡½¨Òe½«Ä¬ÈÏ°²×°Ä¿Â¼´ÓC:\Program Files\Apache Group±a³ÉC:\Apache»oÕßuºÏ8.3ÎļþÃu¸ñʽµÄÆaËuÃu³Æ¡£ÕaÑuÒ»À´£¬ÒÔºoÿ´ÎÊaÈeApache°²×°Â¾¶Ê±£¬¶¼²»±ØΪÆaÌi¼ÓÒýºÅ¡£
¡¡¡¡ÉÔºoƬ¿Ì£¬°²×°Ïoµ¼»a¸aeËßÄaApache 2°²×°³É¹¦¡£½ÓÏÂÀ´Î(C)Ò»Òª×oµÄÊÂÇe¾ÍÊǽøÐвaÊÔ£¬Çe´o¿ªa¯ÀÀÆ÷²¢*ÃÎÊlocalhost£¬ÕaÑuÓ¦¸Ã¿´µ½Ä¬ÈϵÄApache 2Ö÷Ò³¡£
¡¡¡¡È»ºo¿ÉÒÔɾ³ýÖ÷Web*þÎñÆ÷Ŀ¼ÖеÄËuÓÐʾÀýÎļþ£¬ËuÃÇĬÈÏλÓÚC:\InstallDirectory\Apache\Apache2\htdocsÖС£Èç¹uÓÐÒ»¸oÏֳɵÄÖ÷Ò³Index.html£¬Çe°ÑËu¿½±´µ½ÕaÀi£»ÁiÍa£¬Ò²¿ÉÒÔÂiÉÏ´´½¨Ò»¸o¿Õ°×Ö÷Ò³¡£¶ÔÓÚδ³oʼ»¯µÄHTML£¬ÒÔÏ´uÂe¾Í¿ÉÒÔÁË£º
£¼html£¾
£¼head£¾title=default server page£¼/head£¾
£¼body£¾Default server page£¼/body£¾
£¼/html£¾
¡¡¡¡ÈÃApache 2ΪPHP×oºÃ×¼±¸
¡¡¡¡´ÓÏÖÔÚ¿ªÊ¼£¬ÄaÐeÒª½Ï¶aµØÒÔÈ˹¤½Ê½½øÐа²×°£¬²»Äܼoµ¥µØµa»÷ºÍÑ¡Ôñ¼¸¸oÑ¡ÏiÁËÊ¡£¾¡¿iÏ°¹ßËu°É£¬Õa²ÅÊÇApacheµÄ½Ê½¡£ÄaÐeÒª±a¼ÎļþÀ´ÉeÖò»Í¬µÄÅaÖÃÑ¡Ïi£»Èç¹u²Ù×÷²»µ±£¬ÄaËu×oµÄÐ޸ľͻaÁ°ApacheµÄÕýȼÓÔØ¡£Èç¹uÉeÖÃÒý*¢´iÎo£¬ÄÇô´iÎo¿ÉÄܱ»¼Ç¼µ½Apache 2´iÎoÈÕÖ¾ÖУ¨Ä¬ÈÏΪC:\InstallDir\Apache2\Logs\Error.log£(C)¡£µ«Äܹ»ÏñÕaÑu½øÐмǼµÄ±Ï¾¹ÊÇÉÙÊý£¬´o¶aÊý´iÎoÖ»»a¼Ç¼µ½WindowsʼþÈÕÖ¾ÖУ¨¿ªÊ¼| ÉeÖÃ| ¿ØÖÆÃae°a| ¹ÜÀi¹¤¾ß| ʼþ²e¿´Æ÷£(C)¡£
¡¡¡¡ÁiÈËÒź¶µÄÊÇ£¬ÔÚÄa¶Ô°²×°ÉeÖýøÐе÷ÊÔʱ£¬WindowsʼþÈÕÖ¾²¢²»ÊÇÒ»¸o½±aµÄ¹¤¾ß¡£¸uºÃµÄ×o¨ÊÇÔÚÃuÁiÐд°¿ÚÖвaÊÔApache*þÎñÆ÷µÄ¼ÓÔØ£¬ÕaÑuÄÜÁ¢¼´¿´µ½´iÎo±¨¸ae¡£ËuÒÔ£¬ÔÚÍe³ÉÁËÎÒ¼´½«ÌÖÂÛµÄÅaÖÃÐ޸ĺo£¬Çe´o¿ªÒ»¸oÃuÁiÐд°¿Ú£¬Çл»µ½ApacheµÄbinaryĿ¼£¨C:\InstallDir\Apache2\bin£(C)£¬ÔÚÄÇÀiÆo¶¯Apache¡£
¡¡¡¡ApacheÅaÖÃÎļþÊÇC:\Apache\Apache2\Conf\Httpd.conf£¬¿ÉÓÃÈκÎÎı¾±a¼Æ÷À´±a¼¡£²eÕÒDirectoryIndex£¬¶¨Î»µ½ÏÂÃaeÕaÒ»ÐУº
DirectoryIndex index.html index.html.var # index.php
¡¡¡¡ÎªÁËÔÊÐiApache´¦ÀiPHPÒ³£¬ÒªÉ¾³ý×¢ÊÍ×Ö*u£¨#£(C)£¬±a³É£º
DirectoryIndex index.html index.html.var index.php
¡¡¡¡»¹ÒªÔÊÐiÔÚÈκÎĿ¼ÖÐʹÓÃ.htaccessÎļþ£¬ËuÒÔÇeÔÚÅaÖÃÎļþÖвeÕÒAllowOverride£¬°ÑÕa¸oÉeÖôÓNone¸Ä³ÉAll¡£±£´aeÁËËu×oµÄ¸Ä¶¯ºo£¬¿É¼ÌÐøÔÚÎı¾±a¼Æ÷Öдo¿ª¸ÃÎļþ£¬ÒoΪµÈ»a¶u°²×°PHPʱ£¬ÒªÔٴαa¼Õa¸oÎļþ¡£
¡¡¡¡°²×°PHP
¡¡¡¡ËaÈ»¿ÉÒÔÏÂÔØPHPµÄÔ´Âe£¬µ«ºÍApache 2Ò»Ñu£¬×iºÃÖ±½ÓʹÓöþ½øÖÆ¢Ðаu¡£Apache 2¿É²ÉÈ¡2ÖֽʽÀ´ÔËÐÐPHP³ÌÐo£ºÍ¨¹ýÒ»¸oCGI½Ó¿ÚÀ´ÔËÐУ¨Ía²¿µ÷ÓÃPhp.exe£(C)£¬»oÕßʹÓÃPHPµÄDLLÎļþÔÚApacheµÄÄÚ²¿ÔËÐС£ºoÒ»ÖֽʽµÄËٶȽϿi¡£ËuÒÔ£¬Õe¶Ôÿ¸o°ae±¾µÄPHP£¬¶¼»aÌa¹(C)2¸oWindows¶þ½øÖÆ¢Ðаu¡£½ÏСµÄÊÇ.msi°u£¬Ëu»a°²×°CGI¿ÉÖ´ÐгÌÐoPhp.exe£¬µ«ÆaÖÐÄõoÁËͨ¹ýApache DLLÀ´ÔËÐÐPHP½Å±¾ËuÐeµÄÄ£¿e¡£½Ï´oµÄ.zip°uÔo°uº¬ÁËËuÓÐÕaÐ(C)¶«Î÷£¬Äa¿ÉÒÔ´Ósnaps.php.netÍøÕ¾µÄWin32ÇøÓoÏÂÔØËuÃÇ¡£ÎļþÏÂÔØÍe±Ïºo£¬°ÑËu½aѹµ½C:\Php£¨±£ÁoÎļþ¼ÐÃu³Æ£(C)¡£³ý*ÇÄaÓоø¶ÔµÄ°ÑÎÕ£¬ÇeͬʱÏÂÔØPHPÊÖ²a£¬ËuÓжaÖÖÓiÑԵİae±¾¿É¹(C)Ñ¡Ôñ¡£
¡¡¡¡ÅaÖÃApache 2À´ÔËÐÐPHP4
¡¡¡¡ÏÖÔÚÀ´µ½ÁË×iÓÐȤµÄ²¿*Ö£º½«ApacheºÍPHPÍeÃÀµØÅaºÏÆðÀ´¡£Ê×ÏÈ£¬Çe½«C:\Php\DllsĿ¼ÖеÄËuÓÐDLLÎļþ¿½±´µ½WindowsµÄSystemĿ¼£¨%windir%\System£(C)¡£½Ó×Å£¬ÔÚApacheµÄÅaÖÃÎļþ£¨Httpd.conf£(C)ÖвeÕÒ°uº¬ÁË´oÁ¿AddTypeÃuÁiÄǸoС½Ú£¬×Ô¼ºÌi¼ÓÏÂÃaeÕaÒ»ÐУº
AddType application/x-httpd-php .php
¡¡¡¡½«C:\Php\Php.ini-recommended¿½±´µ½WindowsĿ¼£¨%windir%£(C)£¬°ÑËuÖØÃuÃuΪPhp.ini£¬²¢ÓÃÎı¾±a¼Æ÷´o¿ªËu¡£±a¼ÆaÖжÔdoc_root¡¢extension_dirºÍsession.save_path½øÐÐÉeÖõÄ3ÐУ¬Ê¹ÆaºÍÏÂÃaeչʾµÄÒ»Ö£¬×¢ÒaÒª°ÑInstallDirÌae»»³ÉÄaµÄApache 2µÄ°²×°Ä¿Â¼µÄÃu³Æ¡£
doc_root = c:\apache\apache2\htdocs
extension_dir = c:\php\extensions
session.save_path = c:/temp
¡¡¡¡ÔÚsession.save_pathÖÐʹÓÃÕýб¸ÜºÍ´Ð±¸Ü¶¼ÊÇÔÊÐiµÄ¡£PHPÊÖ²aÉu³ÆÕaÐ(C)¾¶²ÎÊýÐeÒªÔÚ×iºoÌi¼ÓÒ»¸o´Ð±¸Ü£¬µ«Õa¸o˵¨ÊDz»ÕýÈ*µÄ¡£ÔÚPHP 4.3Öв»ÐeÒªÕaÑu×o¡£ÁiÍa£¬Èç¹uC:\Temp²»´aeÔÚ£¬Çe×Ô¼º´´½¨Ëu¡£
¡¡¡¡ÏÂÒ»²½ÊÇÔÊÐiApache½«PHP³ÌÐo×÷Ϊģ¿eÀ´ÔËÐУ¬ÕaÒªÇoÄa²ÉÈ¡2¸o²½Öe¡£Ê×ÏÈ£¬½«C:\Php\Php4ts.dll¿½±´µ½WindowsµÄϵͳÎļþ¼Ð£¨%windir%\System£(C)¡£ÔÚHttpd.confÖÐÕÒµ½LoadModuleС½Ú£¬×Ô¼ºÌi¼ÓÏÂÃaeÕaÒ»ÐУº
LoadModule php4_module ¡°c:/php/php4apache2.dll¡±
¡¡¡¡Èç¹uÄa³oÓÚijÖÖÔÒo¶øÐeÒªÔÚCGIģʽÖÐÔËÐÐPHP³ÌÐo£¨Ê¹ÓÃPhp.exe£(C)£¬Çe½«ÉÏÃaeÕaÒ»Ðбa³É×¢ÊÍ£¬²¢ÔÚHttpd.confÖÐÌi¼ÓÏÂÃaeÕaÐ(C)ÐУº
ScriptAlias /php/ "c:/php/"
Action application/x-httpd-php "/php/php.exe"
¡¡¡¡Ò»Çж¼¸a¶¨ÁËÂð?
¡¡¡¡±£´aeËu×oµÄ¸u¸Äºo£¬ÄaÐeÒªÇ××ÔÈ¥Ö¤Ã÷Á½µa£¬²ÅÄÜȱ£Apache 2/PHP 4³ÉΪһ¶ÔÍeÃÀµÄ´iµµ£ºApacheÄÜÕý³£¼ÓÔØÂð£¬ËuÄÜÕýÈ´¦ÀiPHPÒ³Âð£¿
¡¡¡¡ÒªÖªµÀApacheÊÇ*ñÄܹ»Õý³£¼ÓÔØ£¬ÔÚÄaÒѾ´o¿ªµÄÃuÁiÐд°¿ÚÖÐÊaÈeÒÔÏÂÃuÁi£º
apache ¨Ck start
¡¡¡¡ÁiÍa£¬Èç¹uApacheÕýÔÚÔËÐУ¬¿ÉÓÃÒÔÏÂÃuÁiÖØÐÂÆo¶¯Ëu£º
apache ¨Ck restart
¡¡¡¡´ÓÃuÁiÐÐÆo¶¯ApacheµÄºÃ´¦ÔÚÓÚ£¬Èç¹u³oÏÖÒ»¸o´iÎo£¬Apache»aÁ¢¼´±¨¸aeËu¡£Äa¿ÉÄÜÓoµ½µÄ×i³£¼uµÄÎÊÌaÔÚÓÚ£¬Apache¿ÉÄÜÓÉÓÚijÖÖÔÒo¶øÎÞ¨¼ÓÔØPhp4apache2.dll¡£Èç¹uApache±¨¸aeÁËÕa¸o´iÎo£¬Çe°´Ç°ÃaeËuÊoµÄ²½ÖeÖØвÙ×÷Ò»±e£¬È±£Ò»Çж¼Ã»ÓдiÎo¡£
¡¡¡¡ÒªÖªµÀApacheÊÇñÄÜÕýȵش¦ÀiPHPÒ³£¬ÇeÓÃÄaµÄÎı¾±a¼Æ÷´´½¨Ò»¸o¼oµ¥µÄPHPÒ³£¬ÃuÃuΪPhptest.php£¬ÆaÖÐÖ»°uº¬ÏÂÃaeÕaÒ»ÐУº
£¼? phpinfo(); ?£¾
¡¡¡¡½«Îļþ±£´aeµ½Ö÷WebþÎñÆ÷Ŀ¼£¨C:\InstallDirectory\Apache\Apache2\Htdocs£(C)£¬ÓÃa¯ÀÀÆ÷ÃÎÊhttp://localhost/phptest.php¡£Èç¹uÒ»ÇÐÕý³££¬Ó¦¸Ã¿´µ½Ò»¸oº¬ÓÐPHP»Õ±eµÄÍøÒ³£¬ÆaÖаuº¬´oÁ¿ÉeÖúÍÆaËuÐÅÏ¢¡£ÒªÖªµÀPHPµ±Ç°ÊÇͨ¹ýCGIÀ´ÔËÐУ¬»¹ÊÇÔÚApacheÄÚ²¿ÔËÐУ¬¿ÉÒÔ¼i²eһϻ*¾³±aÁ¿orig_script_name¡£Èç¹uPHPͨ¹ýCGIÀ´ÔËÐУ¬Õa¸o±aÁ¿µÄÖµ¾ÍÊÇ/Php/Php.exe¡£Èç¹uApache½«PHP½Å±¾×÷Ϊģ¿eÀ´ÔËÐУ¬¸Ã±aÁ¿µÄÖµÓ¦¸ÃÊÇ/Phptest.php¡£
¡¡¡¡ËaÈ»ÔÚWindowsÉÏ°²×°Apache 2ºÍPHP²¢²»ÊÇÒ»¼þÈÝÒ×µÄÊÂÇe£¬µ«Ò²Íeȫû±ØÒª²ÉÈ¡Ãþ×Åʯ͹ýºÓµÄ×o¨¡£Í¨¹ý±¾ÎĵÄ˵Ã÷£¬ÄaÓ¦¸Ã¿ÉÒÔ¿iËÙ´i½¨ÆðÕa¸oÊÉÏ×iºÃµÄ¡¢³É±¾×iµÍµÄWeb¿ª¢»*¾³¡£