一、解决依赖关系:
若是想让编译的php支持mcrypt扩展,须要下载以下两个rpm包并安装之:
libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpmphp
注:www.rpmfind.net
二、编译安装php-5.4.13
首先下载源码包至本地目录。html
# tar xf php-5.4.13.tar.bz2 # cd php-5.4.13 # ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts # make # make test # make intall
说明:
(一、这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。
(二、若是使用PHP5.3以上版本,为了连接MySQL数据库,能够指定mysqlnd,这样在本机就不须要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,能够编译时绑定到它(而不用和具体的MySQL客户端库绑定造成依赖),但从PHP 5.4开始它就是默认设置了。mysql
# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
(三、--with-apxs2=/usr/local/apache/bin/apxs表示将php编译为httpd模块,若是要要以fcgi模式与http结合需将此项替换为--enable-fpm
sql
为php提供配置文件:数据库
# cp php.ini-production /etc/php.ini
三、 编辑apache配置文件httpd.conf,以apache支持php
apache
# vim /etc/httpd/httpd.conf
一、添加以下二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
二、定位至DirectoryIndex index.html
修改成:
DirectoryIndex index.php index.html
然后从新启动httpd,或让其从新载入配置文件便可测试php是否已经能够正常使用。
vim