php5 与 Apache 2.2 的集成
第一步: 下载并安装 php5下载 zip 版本的最新 php 发行版。
目前最新的是 5.2.6 (php-5.2.6-Win32.zip)。将其解压缩在 C:/apps 下面
第二步:设置PHP 相关环境变量定义一个 PHPRC 的系统变量,
PHPRC=C:/apps/php-5.2.6-Win32。
并将其加载 PATH 变量的最后 ;%PHPRC%
第三步:修改 php.ini 文件建议使用默认的 php.ini-recommended。将其重命名为 php.ini 并放在 C:/apps/php-5.2.6-Win32 下面。在这个文件中根据需要修改配置,在 Windows 平台上有一个变量务必要设置:
extension_dir = "ext/"
第四步:编辑 httpd.conf一个比较合理的办法是把 php 相关的配置信息单独放在一个文件中,然后从 httpd.conf 中 include。
1. 将以下内容保存在一个 httpd-php.conf 文件中,并保存在 /conf/extra 下面
# For PHP 5 do something like this:
LoadModule php5_module "c:/apps/php-5.2.6-Win32/php5apache2_2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/apps/php-5.2.6-Win32"
2. 在 httpd.conf 文件中修改以下内容:
LoadModule php5_module "c:/apps/php-5.2.6-Win32/php5apache2_2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/apps/php-5.2.6-Win32"
a. 在 DirectoryIndex 属性最后加上 index.php
b. 在 httpd.conf 文件最后加上:
# PHP configuration file
Include conf/extra/httpd-php.conf
Include conf/extra/httpd-php.conf