ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾PHP ±à³Ì£¾PHP5ÖÐÎÄÊÖ²á
PHP5ÖÐÎÄÊÖ²á

°²×°³£¼ûÎÊÌâ

±¾Õ°üÀ¨ÁË°²×° PHP µÄ³£¼ûÎÊÌâ¡£PHP ¿ÉÒÔÓÃÓÚ¼¸ºõÈκβÙ×÷ϵͳ£¨¿ÉÄܳýÁË OS X ֮ǰµÄ MacOS Ö®Í⣩£¬ÒÔ¼°¼¸ºõÈκΠweb ·þÎñÆ÷¡£

Òª°²×° PHP£¬Çë°´ÕÕ°²×°ÓëÅäÖÃÒ»ÕÂÖеÄָʾ½øÐС£

  1. a£¬oa»€a1ˆa£¬ao”e¡¥£¤aœ¡§aRže™…e¿a½œcŽ¡¥a¡éƒa£¬-cš„ Apache2 a£¬-a½¿c”¡§co¿c¡§‹aŒ–cš„ MPMi¼Ÿ
  2. Unix/Windowsi¼šao”e¡¥£¤a£¬Ša“aa„¿aŽ»a‰¾aˆ‘cš„ php.ini a–‡a»¶i¼Ÿ
  3. Unixi¼šaˆ‘aR‰e¡ê…ao† PHPi¼Œa½†a¡¥a¬!aˆ‘a‰“a¼€a£¬€a£¬ae!¦Ìe¡éa—¶i¼Œaaa¾—aˆ¡ãa£¬€a!a€œDocument Contains No Dataa€a¶ˆa¡¥i¼e¿™a˜¡¥a€Ža1ˆa›žao‹i¼Ÿ
  4. Unixi¼šaˆ‘a»Ž RPMS aR‰e¡ê…ao† PHPi¼Œa½†a˜¡¥ Apache a£¬a¡è„c† PHP e!¦Ìe¡éi¼e¿™a˜¡¥a€Ža1ˆa›žao‹i¼Ÿ
  5. Unixi¼šaˆ‘a»Ž RPMS aR‰e¡ê…ao† PHP 3i¼Œa½†aRƒa2!aœ‰aŠŠaˆ‘eœ€e|cš„a•¡ãaRao“a”¡¥aŒc¼–e¡¥‘e¿›aŽ»i¼e¿™a˜¡¥a€Ža1ˆa›žao‹i¼Ÿ
  6. Unixi¼šaˆ‘c»™ Apache aŠ a£¬Šao† FrontPage extensions e!£¤a£¬i¼Œc»“ažœ PHP cac„¶a£¬a¡¤£¤a½œao†a€‚PHP a’Œ Apache FrontPage extensions a…¼aR1a—i¼Ÿ
  7. Unix/Windowsi¼šaˆ‘a¡¤2c»aR‰e¡ê…ao† PHPi¼Œa½†a½“aˆ‘e¡¥•c€e€še¿‡a¦Ìe¡ìˆa™¡§eR¿e—R PHP e„šaœ¬a—¶i¼Œa¾—aˆ¡ãao†a£¬€a£¬accoc™½e!¦Ìe¡éa€‚
  8. Unix/Windowsi¼šaˆ‘a¡¤2c»aR‰e¡ê…ao† PHPi¼Œa½†a½“aˆ‘e¡¥•c€e€še¿‡a¦Ìe¡ìˆa™¡§eR¿e—R PHP e„šaœ¬a—¶i¼Œa¾—aˆ¡ãao†a£¬€a£¬aaœaŠ!a™¡§cš„ 500 e”™e¡¥¡¥a€‚
  9. aŸao›a“a½œc3»c»Ÿi¼šaˆ‘a¡¤2c»aœ¡§a£¬a‡oe”™cš„aƒ…a†¦Ìa£¬‹aR‰e¡ê…ao† PHPi¼Œa½†a½“aˆ‘e¡¥•c€a¡¥aŠ¡§ Apache a—¶a¾—aˆ¡ãao†a£¬€a£¬aaœaaRša1‰c¬|a¡¤e”™e¡¥¡¥i¼š [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress
  10. Windowsi¼šaˆ‘a¡¤2c»aR‰e¡ê…ao† PHPi¼Œa½†a½“aˆ‘e¡¥•c€e€še¿‡a¦Ìe¡ìˆa™¡§eR¿e—R PHP e„šaœ¬a—¶i¼Œa¾—aˆ¡ãa|‚a£¬‹e”™e¡¥¡¥i¼š cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
  11. Windowsi¼šaˆ‘a¡¤2c»c…¡ìc€a‰€aœ‰cš„e¡¥¡¯a˜Žašao†i¼Œa½†e¿˜a˜¡¥a£¬eƒ½eRc PHP a’Œ IIS a£¬€e¦Ì¡¤a¡¤£¤a½œi¼
  12. a½“aœ¡§ IISi¼ŒPWSi¼ŒOmniHTTPD aˆ–e€… Xitami a£¬-a»£¤ CGI a–1a¼e¿e!Œ PHP a—¶i¼Œa‡ocŽ¡ãa|‚a£¬‹e”™e¡¥¡¥i¼šSecurity Alert! PHP CGI cannot be accessed directly..
  13. a€Ža ¡¤a¾—cŸ£¤aˆ‘cš„ php.ini a˜¡¥a|e¡é«a‰¾aˆ¡ãa’Œao”c”¡§ao†i¼Ÿa¼¼a1Žaˆ‘ašcš„a¿Ra”1eƒ½a2!aœ‰c”Ÿa•ˆa€‚
  14. a€Ža ¡¤a¡ã† PHP c›Ra½•aŠ a…£¤aˆ¡ã Windows e¡¤¡¥a¾„ PATH a£¬-aŽ»i¼Ÿ
  15. a€Ža ¡¤a½¿ php.ini a–‡a»¶aœ¡§ Windows a£¬‹e¡é« PHP a‰€c”¡§i¼Ÿ
  16. aœ‰a¡¥eƒ½a½¿ PHP e¿a½œaoŽ Apache cš„ content negotiationi¼ˆMultiViews e€‰e!1i¼‰a—i¼Ÿ
  17. PHP a˜¡¥a|a»…e™aoŽa¡è„c† GET a’Œ POST e¡¥¡¤a¡À‚a–1a3•i¼Ÿ
  18. Ϊʲô²»Ó¦¸ÃÔÚʵ¼ÊÔË×÷»·¾³ÖÐµÄ Apache2 ÖÐʹÓÃÏ̻߳¯µÄ MPM£¿

    PHP ÊÇÕ³ºÏ¼Á¡£Ëü½«¼¸Ê®ÖÖµÚÈý·½µÄ¿âÕ³ºÏµ½Ò»ÆðÀ´´´½¨ºÜ¿áµÄ web Ó¦Ó㬲¢Í¨¹ýºÜÖ±¹ÛÇÒÒ×ÓÚѧϰµÄÓïÑÔ½çÃæʹÆä¿´ÉÏÈ¥ºÃÏñÒ»¸öÕûÌå¡£PHP µÄÁé»îÓëÇ¿´óÒÀÀµÓڵײãƽ̨µÄÎȶ¨ÓëÄÍÓá£ÆðÂëÐèÒª½«Ò»¸ö¿ÉÔË×÷µÄ²Ù×÷ϵͳ£¬Ò»¸ö¿ÉÔË×÷µÄ web ·þÎñÆ÷ÒÔ¼°¿ÉÔË×÷µÄµÚÈý·½¿âÕ³ºÏÆðÀ´¡£ÆäÖÐÈκÎÒ»·½²»ÔË×÷ÁË£¬PHP ¶¼ÐèÒªÓз½·¨À´Ê¶±ð³öÎÊÌâ²¢ÇÒ¿ìËÙ½â¾ö¡£Èç¹ûûÓÐÍêÈ«¶ÀÁ¢µÄÖ´ÐÐỊ̈߳¬ÍêÈ«¶ÀÁ¢µÄÄÚ´æµ¥ÔªºÍÎȶ¨µÄ¿Õ¼ä¶Ô¸¶Ã¿¸öÇëÇó£¬Äǵײã¼Ü¹¹¾ÍÌ«¸´ÔÓÒÔÖÁÓÚ²»Îȶ¨ÒòËظüÈÝÒ×½øÈëµ½ PHP ϵͳÖС£

    Èç¹û±ØÐëÒªÓÃÏ̻߳¯µÄ MPM£¬¿´¿´ FastCGI ÅäÖã¬Ê¹ PHP ÔËÐÐÓÚ×Ô¼º¶ÀÁ¢µÄÄÚ´æ¿Õ¼äÖС£

    ×îºóÐèÒªÖ¸³ö£¬²»Ê¹ÓÃÏ̻߳¯ MPM µÄ¾¯¸æÔÚ Windows ϵͳÖÐûÄÇôǿÁÒ£¬ÒòΪ Windows ÖеĴó¶àÊý¿â¶¼ÀíÓ¦ÔÚ¶àÏß³ÌÏ°²È«ÔËÐС£

    Unix/Windows£ºÓ¦¸ÃÉÏÄĶùÈ¥ÕÒÎÒµÄ php.ini Îļþ£¿

    UNIX ÖÐĬÈÏÔÚ /usr/local/lib Ŀ¼ÖУ¬Ò²¾ÍÊÇ <install-path>/lib¡£ºÜ¶àÈË»áÔÚ±àÒëʱͨ¹ý --with-config-file-path ±ê¼ÇÀ´¸Ä±ä·¾¶¡£ÀýÈç¿ÉÒÔ½«Â·¾¶ÉèΪ£º

    --with-config-file-path=/etc
          
    È»ºó´Ó·¢ÐаüÖн« php.ini-dist ¿½±´Îª /etc/php.ini ²¢±à¼­ËüÀ´×÷³öÏëÒªµÄÐ޸ġ£

    --with-config-file-scan-dir=PATH
         

    Windows ÖÐ php.ini ÎļþµÄĬÈÏ·¾¶ÔÚ Windows Ŀ¼Ï¡£Èç¹ûʹÓõÄÊÇ Apache ·þÎñÆ÷£¬Ôò»áÊ×ÏÈÔÚ Apache µÄ°²×°Ä¿Â¼ÖÐÑ°ÕÒ php.ini£¬ÀýÈç C:\Program Files\Apache Group\Apache¡£ÕâÑùͬһ̨»úÆ÷Éϲ»Í¬°æ±¾µÄ Apache ¾Í¿ÉÒÔÓв»Í¬µÄ php.ini Îļþ¡£

    ²Î¼ûÅäÖÃÎļþ¡£

    Unix£ºÎÒ°²×°ÁË PHP£¬µ«Ã¿´ÎÎÒ´ò¿ªÒ»¸öÒ³Ãæʱ£¬Ö»µÃµ½Ò»Ìõ¡°Document Contains No Data¡±ÏûÏ¢£¡ÕâÊÇÔõô»ØÊ£¿

    Õâ¿ÉÄÜÒâζ×Å PHP ·¢ÉúÁËijÀà´íÎó¶øµ¼ÖÂÁË core dump¡£²é¿´·þÎñÆ÷µÄ´íÎóÈÕÖ¾¿´¿´ÊDz»ÊÇÕâÑù£¬ÔÙÓÃÒ»¸öСµÄ²âÊÔÀý×ÓÊÔ×ÅÖØÏÖ´ËÎÊÌâ¡£Èç¹ûÄã»áÓá°gdb¡±µÄ»°£¬ÄÇôÔÚ bug ±¨¸æÖÐÌṩ»ØËݸú×ÙºÜÓÐÖúÓڰ↑·¢ÈËÔ±²éÃ÷ÎÊÌâ¡£Èç¹ûÄãÓà Apache µÄÄ£¿é·½Ê½Ê¹Óà PHP£¬ÊÔ×ÅÕâô×ö£º

    • Í£Ö¹ httpd ½ø³Ì

    • gdb httpd

    • Í£Ö¹ httpd ½ø³Ì

    • > run -X -f /path/to/httpd.conf

    • È»ºóÔÚÄãµÄä¯ÀÀÆ÷ÖзÃÎʵ¼Ö´íÎóµÄ URL

    • > run -X -f /path/to/httpd.conf

    • Èç¹ûÄãÓöµ½ core dump£¬gdb ´Ëʱ¾Í»á֪ͨÄã

    • ÊäÈ룺bt

    • ÄãÓ¦¸ÃÔÚ bug ±¨¸æÖаüÀ¨»ØËÝ×·×ټǼ¡£Ó¦¸ÃÌá½»µ½ » http://bugs.php.net/

    Èç¹ûÄãµÄ½Å±¾Ê¹ÓÃÁËÕýÔò±í´ïʽº¯Êý£¨ereg() µÈ£©£¬Ó¦¸ÃÈ·ÈÏÔÚ±àÒë PHP ºÍ Apache ʱʹÓÃÁËͬһ¸öÕýÔò±í´ïʽ°ü¡£ÔÚ PHP ºÍ Apache 1.3.x ÖÐÓ¦¸Ã×Ô¶¯¾ÍÊÇÕâÑù¡£

    Unix£ºÎÒ´Ó RPMS °²×°ÁË PHP£¬µ«ÊÇ Apache ²»´¦Àí PHP Ò³Ã棡ÕâÊÇÔõô»ØÊ£¿

    ¼Ù¶¨ÄãµÄ Apache ºÍ PHP ¶¼ÊÇ´Ó RPM °üÖа²×°µÄ£¬ÄãÐèÒªÔÚ httpd.conf ÎļþÖÐÈ¡ÏûÒÔϲ¿·Ö»òËùÓÐÐеÄ×¢ÊÍ£¬»òÕß°ÑËüÃÇÌí¼Óµ½¸ÃÎļþÖУº

    # Extra Modules
    AddModule mod_php.c
    AddModule mod_php3.c
    AddModule mod_perl.c
    
    # Extra Modules
    LoadModule php_module         modules/mod_php.so
    LoadModule php3_module        modules/libphp3.so     # for PHP 3
    LoadModule php4_module        modules/libphp4.so     # for PHP 4
    LoadModule perl_module        modules/libperl.so
    
    ²¢ÇÒ°Ñ£º
    AddType application/x-httpd-php3 .php3    # for PHP 3
    AddType application/x-httpd-php .php      # for PHP 4
    
    Ìí¼Óµ½È«¾ÖÊôÐÔÖУ¬»òÕßÌí¼Óµ½ÄãÏ£Íû¼ÓÈë PHP Ö§³ÖµÄÐéÄâÓòÖС£

    Unix£ºÎÒ´Ó RPMS °²×°ÁË PHP 3£¬µ«ËüûÓаÑÎÒÐèÒªµÄÊý¾Ý¿âÖ§³Ö±àÒë½øÈ¥£¡ÕâÊÇÔõô»ØÊ£¿

    ÓÉÓÚ PHP 3 ¹¹ÔìµÄÔ­Òò£¬²»ÈÝÒ×±àÒë³öÒ»¸öÍêÈ«Áé»îµÄ PHP RPM °üÀ´¡£Õâ¸öÎÊÌâÔÚ PHP 4 Öнâ¾öÁË¡£¶ÔÓÚ PHP 3 À´Ëµ£¬ÎÒÃÇÄ¿Ç°½¨ÒéÄãÓà PHP ·¢ÐаüÖÐ INSTALL.REDHAT ÎļþÖÐËùÃèÊöµÄ»úÖÆ¡£Èç¹ûÄã¼á³ÖÒªÓà PHP 3 µÄ RPM °æ±¾£¬Çë½Ó×ÅÍùÏ¿´¡£

    ΪÁ˼ò»¯°²×°ÒÔ¼°ÓÉÓÚ RPMS ʹÓÃÁË /usr/ ¶ø²»ÊDZê×¼µÄ /usr/local/ Ŀ¼À´´æ·ÅÎļþ£¬ÖÆ×÷ RPM °üµÄÈËÉ趨 RPMS ²»°²×°ÈκÎÊý¾Ý¿âÖ§³Ö¡£ÄãÐèÒª¸æËß RPM ˵Ã÷Îļþ£¬ÄãÏëÒªÖ§³ÖÄĸöÊý¾Ý¿âÒÔ¼°ÄãµÄÊý¾Ý¿â·þÎñÆ÷×î¸ß²ã·¾¶¡£

    ÏÂÃæµÄÀý×Ó½â˵ÁËÈçºÎÔÚÓÃÄ£¿é°²×°Ï嵀 Apache ÖмÓÈëÁ÷ÐÐµÄ MySQL Êý¾Ý¿â·þÎñÆ÷Ö§³ÖµÄ¹ý³Ì¡£

    µ±È»ÕâЩÐÅÏ¢¿ÉÒÔµ÷ÕûÓÃÓÚÈκΠPHP Ö§³ÖµÄÊý¾Ý¿â·þÎñÆ÷¡£±¾ÀýÖÐÎÒÃÇÒ²¼Ù¶¨Äã´Ó RPMS ÖÐÍêÕû°²×°ÁË MySQL ºÍ Apache¡£

    • ÏÈÈ¥µô mod_php3£º

      rpm -e mod_php3
               

    • È»ºóÈ¡µÃÔ´ÎļþµÄ rpm °ü²¢°²×°Ëü£¬¶ø²»ÊDZàÒëËü¡£

      rpm -Uvh mod_php3-3.0.5-2.src.rpm
               

    • ½Ó×ű༭ /usr/src/redhat/SPECS/mod_php3.spec Îļþ

      ÔÚ %build Ò»½Ú¼ÓÈëÄãÏëÒªµÄÊý¾Ý¿âÖ§³Ö£¬ÒÔ¼°Â·¾¶¡£

      ¶ÔÓ¦ÓÚ MySQL ÄãÓ¦¸Ã¼ÓÈë --with-mysql=/usr¡£Ôò %build Ò»½Ú¿´ÉÏÈ¥½«ÀàËÆÕâÑù£º

      ./configure --prefix=/usr \
      --with-apxs=/usr/sbin/apxs \
      --with-config-file-path=/usr/lib \
      --enable-debug=no \
      --enable-safe-mode \
      --with-exec-dir=/usr/bin \
      --with-mysql=/usr \
      --with-system-regex
               

    • Ò»µ©Íê³ÉÁËÕâ¸öÐ޸ģ¬¾ÍÕâÑù½¨Á¢¶þ½øÖƳÌÐòµÄ rpm °ü£º

      rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
               

    • È»ºó°²×° rpm

      rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
               

    È·ÈÏÖØÐÂÆô¶¯ÁË Apache£¬ÕâÏÂÄã¾ÍÓÐÁËÓà RPM °²×°µÄ²¢ÇÒ´ø MySQL Ö§³ÖµÄ PHP 3 ÁË¡£×¢Òâ°´ÕÕ PHP 3 ·¢ÐаüÖÐ INSTALL.REDHAT ÎļþµÄ˵Ã÷À´±àÒëÆäʵҲÐí¸üÈÝÒ×һЩ¡£

    Unix£ºÎÒ¸ø Apache ¼ÓÉÏÁË FrontPage extensions ²¹¶¡£¬½á¹û PHP ͻȻ²»¹¤×÷ÁË¡£PHP ºÍ Apache FrontPage extensions ¼æÈÝÂð£¿

    ¼æÈݵġ£PHP ¿ÉÒÔºÍ FrontPage extensions Ò»Æð¹¤×÷£¬ÎÊÌâÊÇ FrontPage ²¹¶¡ÐÞ¸ÄÁ˼¸¸ö PHP ÒÀÀµµÄ Apache ¹¹Ôì¡£ÔÚ FrontPage ²¹¶¡°²×°Ö®ºóÖ®ºóÖØбàÒë PHP£¨Óá°make clean ; make¡±£©¿ÉÒÔ½â¾ö´ËÎÊÌâ¡£

    Unix/Windows£ºÎÒÒѾ­°²×°ÁË PHP£¬µ«µ±ÎÒÊÔ×Åͨ¹ýä¯ÀÀÆ÷·ÃÎÊ PHP ½Å±¾Ê±£¬µÃµ½ÁËÒ»¸ö¿Õ°×Ò³Ãæ¡£

    ÓÃä¯ÀÀÆ÷Öеġ°²é¿´Ô´Îļþ¡±£¬Äã¿ÉÄܻᷢÏÖÄÜ¿´µ½ PHP ½Å±¾µÄÔ´³ÌÐò¡£ÕâÒâζ×Å web ·þÎñÆ÷ûÓаѽű¾·¢Ë͸ø PHP ½âÊÍ¡£·þÎñÆ÷ÅäÖÃÔÚij´¦ÓÐÎÊÌ⣬Çë¶ÔÕÕ PHP °²×°ËµÃ÷×Ðϸ¼ì²é·þÎñÆ÷ÅäÖá£

    Unix/Windows£ºÎÒÒѾ­°²×°ÁË PHP£¬µ«µ±ÎÒÊÔ×Åͨ¹ýä¯ÀÀÆ÷·ÃÎÊ PHP ½Å±¾Ê±£¬µÃµ½ÁËÒ»¸ö·þÎñÆ÷µÄ 500 ´íÎó¡£

    µ±·þÎñÆ÷³¢ÊÔÔËÐÐ PHP ʱ³öÁË´í¡£ÒªÏë¿´µ½ÓÐÒâÒåµÄ´íÎóÐÅÏ¢£¬ÔÚÃüÁîÐÐÖÐתµ½ PHP ¿ÉÖ´ÐгÌÐò£¨Windows ÖÐÊÇ php.exe£©ËùÔÚĿ¼Ï²¢ÔËÐÐ php -i¡£Èç¹û PHP ÔËÐÐÓÐÈκÎÎÊÌ⣬ÄÇô»áÏÔʾÏàÓ¦µÄ´íÎóÐÅÏ¢£¬Õ⽫¸øÄãÏÂÒ»²½Òª×öʲôµÄÏßË÷¡£Èç¹ûÄãµÃµ½ÂúÆÁÄ» HTML ´úÂ루phpinfo() º¯ÊýµÄÊä³ö£©µÄ»°ËµÃ÷ PHP ±¾Éí¹¤×÷Õý³££¬ÄãµÄÎÊÌâ¿ÉÄܺÍÄãµÄ·þÎñÆ÷ÅäÖÃÓйأ¬Òª×Ðϸ¼ì²é¡£

    ijЩ²Ù×÷ϵͳ£ºÎÒÒѾ­ÔÚ²»³ö´íµÄÇé¿öÏ°²×°ÁË PHP£¬µ«µ±ÎÒÊÔ×ÅÆô¶¯ Apache ʱµÃµ½ÁËÒ»¸ö䶨Òå·ûºÅ´íÎó£º

    [mybox:user /src/php4] root# apachectl configtest
     apachectl: /usr/local/apache/bin/httpd Undefined symbols:
      _compress
      _uncompress
          

    Õâʵ¼ÊÉÏºÍ PHP ûÓйØϵ£¬¶øºÍ MySQL µÄ¿Í»§¶Ë¿âÓйء£ÓеÄÐèÒª --with-zlib£¬ÓеIJ»ÐèÒª¡£Õâ¸öÎÊÌâÒ²°üÀ¨ÔÚ MySQL µÄ FAQ ÖС£

    Windows£ºÎÒÒѾ­°²×°ÁË PHP£¬µ«µ±ÎÒÊÔ×Åͨ¹ýä¯ÀÀÆ÷·ÃÎÊ PHP ½Å±¾Ê±£¬µÃµ½ÈçÏ´íÎó£º

    cgi error:
     The specified CGI application misbehaved by not
     returning a complete set of HTTP headers.
     The headers it did return are:
          

    Õâ¸ö´íÎóÐÅÏ¢Òâζ×Å PHP ¸ù±¾¾Í²»ÄܲúÉúÈκÎÊä³ö¡£ÒªÏë¿´µ½ÓÐÒâÒåµÄ´íÎóÐÅÏ¢£¬ÔÚÃüÁîÐÐÖÐתµ½ PHP ¿ÉÖ´ÐгÌÐò£¨Windows ÖÐÊÇ php.exe£©ËùÔÚĿ¼Ï²¢ÔËÐÐ php -i¡£Èç¹û PHP ÔËÐÐÓÐÈκÎÎÊÌ⣬ÄÇô»áÏÔʾÏàÓ¦µÄ´íÎóÐÅÏ¢£¬Õ⽫¸øÄãÏÂÒ»²½Òª×öʲôµÄÏßË÷¡£Èç¹ûÄãµÃµ½ÂúÆÁÄ» HTML ´úÂ루phpinfo() º¯ÊýµÄÊä³ö£©µÄ»°ËµÃ÷ PHP ±¾Éí¹¤×÷Õý³£¡£

    Ò»µ© PHP ÔÚÃüÁîÐÐÖй¤×÷Õý³££¬ÊÔ×Åͨ¹ýä¯ÀÀÆ÷ÔٴηÃÎʽű¾¡£Èç¹û»¹Ê§°ÜµÄ»°ÄÇ¿ÉÄÜÊÇÈçÏÂÔ­ÒòÖ®Ò»£º

    • ÎļþȨÏÞÎÊÌ⣬ÄãµÄ PHP ½Å±¾£¬php.exe£¬php4ts.dll£¬php.ini »òÈκÎÄãÒª¼ÓÔØµÄ PHP À©Õ¹¿âÊÇÄäÃû internet Óû§ ISUR_<machinename> ÎÞȨ·ÃÎʵġ£
    • ½Å±¾Îļþ²»´æÔÚ£¨»òÕßÓпÉÄܲ»ÔÚÄãÒÔΪµÄµØ·½£¬×¢Òâ web ÎĵµµÄĿ¼£©¡£×¢ÒâÔÚ IIS ÖÐͨ¹ý Internet ·þÎñ¹ÜÀíÆ÷É趨½Å±¾Ó³ÉäʱѡÖС°¼ì²éÎļþÊÇ·ñ´æÔÚ¡±¿ÉÒÔ²¶×½µ½´Ë´íÎó¡£ÕâÑùÒ»À´Èç¹û½Å±¾Îļþ²»´æÔڵĻ°·þÎñÆ÷¾Í»á·µ»ØÒ»¸ö 404 ´íÎóÐÅÏ¢¡£»¹ÓÐÒ»¸ö¶îÍâµÄºÃ´¦¾ÍÊÇ IIS »á»ùÓÚ NTLanMan ȨÏÞÀ´ÌæÄã¶Ô½Å±¾Îļþ×öÈκÎËùÐèÒªµÄÈÏÖ¤¡£

    Windows£ºÎÒÒѾ­ÕÕ×ÅËùÓеÄ˵Ã÷×öÁË£¬µ«»¹ÊDz»ÄÜÈà PHP ºÍ IIS Ò»Æð¹¤×÷£¡

    È·ÈÏÐèÒªÔËÐÐ PHP ½Å±¾µÄÈκÎÓû§ÓÐȨÏÞÔËÐÐ php.exe£¡IIS ʹÓÃÁËÒ»¸öÔÚ°²×° IIS ʱÌí¼ÓµÄÄäÃûÓû§£¬Õâ¸öÓû§ÐèÒªÓзÃÎÊ php.exe µÄȨÏÞ¡£Í¬ÑùÈκÎÈÏÖ¤Óû§Ò²ÐèÒªÖ´ÐÐ php.exe µÄȨÏÞ¡£ÔÚ IIS4 ÖÐÄ㻹ÐèÒª¸æËßËü PHP ÊÇÒ»¸ö½Å±¾ÒýÇæ¡£´ËÍ⣬Äã¿ÉÄÜ»¹ÐèÒªÔĶÁ´Ë³£¼ûÎÊÌâ¡£

    µ±ÔÚ IIS£¬PWS£¬OmniHTTPD »òÕß Xitami ÖÐÒÔ CGI ·½Ê½ÔËÐÐ PHP ʱ£¬³öÏÖÈçÏ´íÎó£ºSecurity Alert! PHP CGI cannot be accessed directly..

    ±ØÐ뽫 cgi.force_redirect Ñ¡ÏîÉèΪ 0¡£ ĬÈÏֵΪ 1£¬Òò´ËҪȷÈÏ´ËÑ¡ÏîûÓб»×¢Ê͵ô£¨Óà ;£©¡£ºÍÆäËüÑ¡ÏîÒ»Ñù£¬ÊÇÔÚ php.ini ÖÐÉ趨µÄ¡£

    ÒòΪĬÈÏÖµÊÇ 1£¬Òò´ËÄã±ØÐë°Ù·ÖÖ®°ÙÈ·ÈÏʹÓÃÁËÕýÈ·µÄ php.ini Îļþ¡£ÏêϸÐÅÏ¢ÇëÔĶÁ´Ë³£¼ûÎÊÌâ¡£

    ÔõÑùµÃÖªÎÒµÄ php.ini ÊÇ·ñ±»ÕÒµ½ºÍÓ¦ÓÃÁË£¿ËƺõÎÒ×öµÄÐ޸Ķ¼Ã»ÓÐÉúЧ¡£

    ҪȷÈÏÄãµÄ php.ini ±» PHP ʹÓÃÁË£¬µ÷Óà phpinfo()£¬ÔÚ½Ó½ü¿ªÍ·µÄλÖÃÓÐÒ»Ïî½Ð×ö Configuration File (php.ini)¡£ÕâÀォ¸æËßÄã PHP ÔÚÄÄÀïÕÒµ½ÁË php.ini ²¢ÇÒÊÇ·ñʹÓÃÁË¡£Èç¹ûÖ»ÏÔʾһ¸öĿ¼Ôò ûÓÐʹÓÃÈκΠphp.ini Îļþ£¬ÄãÓ¦½«ÄãµÄ php.ini Îļþ·Åµ½¸ÃĿ¼ÖС£Èç¹û php.ini °üÀ¨Ôڸ÷¾¶ÖÐÔòËüÒѱ»Ó¦ÓÃÁË¡£

    Èç¹û php.ini ±»Ê¹ÓÃÁ˲¢ÇÒÄãÊÇÒÔÄ£¿é·½Ê½ÔËÐÐ PHP µÄ£¬È·±£ÔÚÐÞ¸ÄÁË php.ini Ö®ºóÖØÐÂÆô¶¯ÄãµÄ web server¡£

    ÔõÑù½« PHP Ŀ¼¼ÓÈëµ½ Windows ·¾¶ PATH ÖÐÈ¥£¿

    ÔÚ Windows NT£¬2000£¬XP ºÍ 2003 Ï£º

    • ½øÈë¿ØÖÆÃæ°å²¢´ò¿ª¡°ÏµÍ³¡±Í¼±ê£¨¿ªÊ¼ -> ÉèÖà -> ¿ØÖÆÃæ°å -> ϵͳ£¬Windows XP/2003 ÖÐÊÇ£º¿ªÊ¼ -> ¿ØÖÆÃæ°å -> ϵͳ£©

    • Ñ¡Ôñ¡°¸ß¼¶¡±±êÇ©Ò³

    • µã»÷¡°»·¾³±äÁ¿¡±°´Å¥

    • ÔÚ¡°ÏµÍ³±äÁ¿¡±À¸ÖÐ

    • ÕÒµ½ Path ÕâÒ»Ï¿ÉÄÜÐèÒªÏòϹö¶¯²ÅÄÜÕÒµ½£©

    • Êó±êË«»÷ Path ÕâÒ»Ïî

    • ÔÚ×îºó¼ÓÈëÄãµÄ PHP Ŀ¼£¬°üÀ¨Ç°ÃæµÄ¡°;¡±£¨ÀýÈ磺;C:\php£©

    • µã»÷¡°È·¶¨¡±²¢ÖØÐÂÆô¶¯µçÄÔ

    ÔÚ Windows 98/Me ÖÐÐèÒª±à¼­ autoexec.bat Îļþ£º

    • ´ò¿ª¼Çʱ¾£¨¿ªÊ¼ -> ÔËÐУ¬È»ºóÊäÈë notepad ²¢µãÈ·¶¨£©

    • ´ò¿ª C:\autoexec.bat Îļþ

    • ÕÒµ½ÕâôһÐУºPATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... ²¢ÔÚ×îºó¼ÓÉÏ ;C:\php

    • ±£´æÎļþ²¢ÖØÐÂÆô¶¯µçÄÔ

    Note: ¼ÇסÔÚÉÏÊöÐÞ¸ÄÖ®ºóÖØÐÂÆô¶¯£¬ÒÔÈ·±£¶Ô PATH µÄ¸Ä±äÉúЧ¡£

    PHP ÊÖ²á¹ýÈ¥Ìᳫ°ÑÎļþ¿½±´µ½ Windows ϵͳĿ¼ÖÐÈ¥£¬ÕâÊÇÒòΪ¸ÃĿ¼£¨C:\Windows£¬C:\WINNT£¬µÈµÈ£©Ä¬ÈϾÍÔÚϵͳ·¾¶ÖС£µ«ÊÇ°ÑÎļþ¿½±´µ½ Windows ϵͳĿ¼ÖÐÕâÒ»·½Ê½ÔçÒѲ»±»Ìᳫ£¬»¹¿ÉÄÜÔì³ÉÎÊÌâ¡£

    ÔõÑùʹ php.ini ÎļþÔÚ Windows ϱ» PHP ËùÓã¿

    Óм¸ÖÖ·½·¨¡£Èç¹ûʹÓà Apache£¬ÔĶÁרÃŵݲװָʾ£¨Apache 1£¬Apache 2£©£¬·ñÔò¾Í±ØÐëÉ趨 PHPRC »·¾³±äÁ¿£º

    ÔÚ Windows NT£¬2000£¬XP ºÍ 2003 ÖÖ£º

    • ½øÈë¿ØÖÆÃæ°å²¢´ò¿ª¡°ÏµÍ³¡±Í¼±ê£¨¿ªÊ¼ -> ÉèÖà -> ¿ØÖÆÃæ°å -> ϵͳ£¬Windows XP/2003 ÖÐÊÇ£º¿ªÊ¼ -> ¿ØÖÆÃæ°å -> ϵͳ£©

    • Ñ¡Ôñ¡°¸ß¼¶¡±±êÇ©Ò³

    • µã»÷¡°»·¾³±äÁ¿¡±°´Å¥

    • ÔÚ¡°ÏµÍ³±äÁ¿¡±À¸ÖÐ

    • µã»÷¡°Ð½¨¡±°´Å¥²¢ÔÚ¡°±äÁ¿Ãû¡±ÖÐÊäÈë¡°PHPRC¡±£¬ÔÚ¡°±äÁ¿Öµ¡±ÖÐÊäÈë php.ini ÎļþËùÔÚµÄĿ¼£¨ÀýÈ磺C:\php£©

    • µã»÷¡°È·¶¨¡±²¢ÖØÐÂÆô¶¯µçÄÔ

    ÔÚ Windows 98/Me ÖÐÐèÒª±à¼­ autoexec.bat Îļþ£º

    • ´ò¿ª¼Çʱ¾£¨¿ªÊ¼ -> ÔËÐУ¬È»ºóÊäÈë notepad ²¢µãÈ·¶¨£©

    • ´ò¿ª C:\autoexec.bat Îļþ

    • ÔÚÎļþ½áβ´¦¼ÓÈëÒ»ÐУºset PHPRC=C:\php£¨½« C:\php Ì滻ΪÄãµÄ php.ini ʵ¼Ê´æÔÚµÄĿ¼£©¡£×¢Òâ·¾¶Öв»ÄÜ°üº¬¿Õ¸ñ¡£ÀýÈ罫 PHP °²×°µ½ÁË C:\Program Files\PHP ÖУ¬ÄãÐèÒªÊäÈë C:\PROGRA~1\PHP Ìæ´úÖ®

    • ±£´æÎļþ²¢ÖØÐÂÆô¶¯µçÄÔ

    ÓпÉÄÜʹ PHP ÔË×÷ÓÚ Apache µÄ content negotiation£¨MultiViews Ñ¡ÏÂð£¿

    Èç¹ûµ½ PHP ÎļþµÄÁ¬½Ó°üº¬À©Õ¹Ãû£¬Ò»Çж¼ÔËÐÐÍêÃÀ¡£±¾½â´ðÖ»Õë¶Ôµ½ PHP ÎļþµÄÁ¬½Ó²»°üº¬À©Õ¹Ãûʱ£¬¶øÏ£Íûͨ¹ý content negotiation À´´Ó²»°üº¬À©Õ¹ÃûµÄ URL À´Ñ¡Ôñ PHP ÎļþµÄÇé¿ö¡£ÔÚ´ËÖÖÇé¿öÏ£¬½« AddType application/x-httpd-php .php Ì滻Ϊ£º

    # PHP 4
    AddHandler php-script php
    AddType text/html php
    
    # PHP 5
    AddHandler php5-script php
    AddType text/html php
    
    ´Ë·½°¸¶ÔÓÚ Apache 1 ²»ÊÊÓã¬ÒòΪ PHP Ä£¿é²»²¶»ñ php-script¡£

    PHP ÊÇ·ñ½öÏÞÓÚ´¦Àí GET ºÍ POST ÇëÇó·½·¨£¿

    ²»ÊÇ£¬PHP ÓпÉÄÜ´¦ÀíÈκÎÇëÇó·½·¨£¬ÀýÈç CONNECT¡£Êʵ±µÄ»ØӦ״̬¿ÉÒÔÓà header() ·¢ËÍ¡£Èç¹û½öÐèÒª´¦Àí GET ºÍ POST ·½·¨£¬¿ÉÒÔͨ¹ýÈçÏ嵀 Apache ÅäÖÃʵÏÖ£º

    <LimitExcept GET POST>
    Deny from all
    </LimitExcept>