<h1 class="postTitle" style="font-size: 12px; margin: 10px 0px; padding: 3px; background-color: rgb(255, 255, 255); border-bottom-color: rgb(204, 204, 204); border-bottom-width: 1px; border-bottom-style: dashed; line-height: 19px; widows: 2; font-family: georgia, Verdana, Helvetica, Arial; orphans: 2; color: rgb(170, 170, 170);"><span style="color: rgb(51, 51, 51);"><span style="line-height: 21px; font-size: 14px; font-weight: normal;">1.下载Apache 2.2.15</span></span></h1><div class="postBody" style="text-align: justify; background-color: rgb(255, 255, 255); widows: 2; font-size: 13px; line-height: 19px; font-family: georgia, Verdana, Helvetica, Arial; orphans: 2; color: rgb(170, 170, 170);"><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">http://httpd.apache.org/download.cgi#apache22<;/span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">要下载的是Win32 Binary without crypto (no mod_ssl) (MSI Installer): </span><span style="color: rgb(51, 51, 51);">httpd-2.2.15-win32-x86-no_ssl.msi</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">PS: 天空软件站居然有2.2.4版本(Apache官网才到2.2.15),但确实是可用的,下载链接: </span><span style="color: rgb(51, 51, 51);">http://www.skycn.com/soft/1218.html<;/span></p><div style="page-break-after: always;"><span style="display: none;"><!--more-->& nbsp ;</span></div><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">​</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">2.下载PHP 5.3.2</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">http://windows.php.net/download/<;/span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">这里下载的是VC6 x86 Thread Safe的zip版</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">具体原因参考</span><span style="color: rgb(51, 51, 51);">PHP关于VC9和VC6以及Thread Safe和Non Thread Safe版本选择的问题</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">PS: 切记是要zip版,不要下错Installer版,Installer版有些文件没放在安装目录里面.</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">3.安装Apache和PHP环境</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">为了方便路径配置的,我安装Apache时把路径改为C:Apache,把PHP的zip包解压缩到C:PHP</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">4.配置Apache环境</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> 打开Apache的配置文件C:Apacheconfhttpd.conf</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">1)查找"DocumentRoot",该参数是用来指定Apache的网站根目录,</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">默认值是C:/Apache/htdocs,为了便于调试,我把值改为E:/Website(如果目录不存在,启动Apache服务时会出错)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">2)查找"This should be changed to whatever you set DocumentRoot to."</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">在这行下面有一行<Directory "C:/Apache/htdocs">,改成<Directory "E:/Website"></span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">3)查找"<Directory />",在<Directory />和</Directory>之间有一行"Deny from all",改成"Allow from all"</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">4)查找"DirectoryIndex",在index.html后面加index.php(此为默认首页文件名,可加可不加)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">PS: 配置路径的值是反斜杠'/',不是斜杠'&#39;</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">5.配置PHP环境</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> 在C:PHP中有两个可选的配置文件:php.ini-development和php.ini-production, 用记事本打开php.ini-development</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">1).查找"doc_root",将其值设置为E:/Website(必须跟Apache的DocumentRoot的值一致)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">2)查找"extension_dir",该参数是用来指定扩展插件的dll目录,这里设置为C:PHPext</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">这行一般是被注释掉的,去掉extension_dir前面的";"号即可.</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">3)查找"extension=",反注释下面这两行:(就是把前面的";"号去掉)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">extension=php_gd2.dll</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">extension=php_mysql.dll</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">4)查找"default_charset",默认是iso-8859-1,改成UTF-8(也可以改成GBK)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">5)查找"register_globals",默认是Off,有些系统需要改成On(例如WordPress),有些却需要Off(例如DeDeCMS)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">6)保存php.ini-development,并重命名为php.ini,放到C:WINDOWS</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">7)把php5ts.dll文件放到C:WINDOWSsystem32</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">6.配置Apache和PHP整合</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">1)把php5apache2_2.dll文件放到C:Apachemodules</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">2)打开C:Apacheconfhttpd.conf</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">查找"LoadModule",在LoadModule列表的最后加一行LoadModule php5_module modules/php5apache2_2.dll</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">查找"AddType",在AddType列表的最后加一行AddType application/x-httpd-php .php</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">3)重启Apache服务(Monitor界面的Restart按钮)</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">7.测试环境</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">1)打开IE,输入</span><span style="color: rgb(51, 51, 51);">http://localhost/<;/span><span style="color: rgb(51, 51, 51);">,没报错就是成功了.</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);"> </span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">2)在E:Website目录新建一个"test.php"文件,用记事本编辑文件,输入"<?php phpinfo(); ?>",保存并关闭.</span></p><p style="margin: 5px auto; padding: 0px;"><span style="color: rgb(51, 51, 51);">在IE输入</span><span style="color: rgb(51, 51, 51);">http://localhost/test.php<;/span><span style="color: rgb(51, 51, 51);">,出现PHP的版本信息就代表配置成功了.</span></p></div>