本文为Rainisic http://www.cnblogs.com/rainisic/archive/2012/05/23/Apache_PHP_Install.html 下载PHP 官方下载:http://www.php.net/downloads.php 安装PHP 首先,确保Apache在编译安装时支持PHP模块,详情请参考:http://www.cnblogs.com/rainisic/archi
本文为Rainisic
http://www.cnblogs.com/rainisic/archive/2012/05/23/Apache_PHP_Install.html
官方下载:http://www.php.net/downloads.php
首先,确保Apache在编译安装时支持PHP模块,详情请参考:http://www.cnblogs.com/rainisic/archive/2012/05/23/Linux_Apache2_4_Install.html
解压缩PHP
shell> <span>sudo</span> <span>tar</span> zxvf php-<span>5.4</span>.<span>3</span>.<span>tar</span>.gz /opt/sources
停止Apache服务
shell> <span>sudo</span> service httpd stop
配置安装PHP
shell> cd /opt/sources/php-<span>5.4</span>.<span>3</span><span> shell</span>> <span>sudo</span> ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-<span>mysql shell</span>> <span>sudo</span> <span>make</span><span> shell</span>> <span>sudo</span> <span>make</span> <span>install</span>
配置php.ini
shell> <span>sudo</span> <span>cp</span> php.ini-development /usr/local/lib/php.ini
编辑 httpd.conf 文件以调用 PHP 模块。LoadModule 表达式右边的路径必须指向 系统中的 PHP。以上的 make install 命令可能已经完成了这些,但务必要检查。
LoadModule php5_module modules/libphp5.so
告知 Apache 将特定的扩展名解析成 PHP,例如,让 Apache 将扩展名 .php 解析成 PHP。编辑httpd.conf
<filesmatch><span> SetHandler application</span>/x-httpd-<span>php </span></filesmatch>
按照通常的方式启动 Apache 服务测试即可。