rpm -qa zlib libxml libjpeg freetype libpng gd  curl  libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel

或者
rpm -qa zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel
 
如果没有可以使用yum来安装
yum install zlib libxml libjpeg freetype libpng gd  curl  libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-
 
devel -y
 
安装libiconv库   
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
 
安装PHP
rz 上传php-5.3.10.tar.gz
tar zxf php-5.3.10.tar.gz
cd php-5.3.10
./configure \
--prefix=/usr/local/php5.3.10 \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv=/usr/local/libiconv \
--enable-short-tags \
--enable-sockets \
--enable-zend-multibyte \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml-dir \
--enable-sigchild \
--enable-pcntl \
--enable-bcmath
注意:后面3个为nagio锁需要编译进去
make && make install 
ln -s /usr/local/php5.3.10 /usr/local/php
ls /usr/loacl/php |egrep php.int
php.ini-development 开发版本  php.ini-production 生产环境版本
cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/apache/conf/httpd.cnf /usr/local/apache/conf/httpd.conf.bak
vi httpd.cnf
311行处增加
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
修改apache默认用户和组(不是必须的为了安全)
User myisam
Group myisam
注意:需要添加此用户 useradd myisam -M -s /sbin/nologin
166行处修改首页文件
DirectoryIndex index.php index.html
检查是否有这句加载PHP模块的语句LoadModule php5_module    modules/libphp5.so
 
apachectl -t
apachectl graceful
 
如果出错可以关闭SELINUX
[root@centos5 modules]# /usr/local/apache/bin/apachectl -t
httpd: Syntax error on line 55 of /usr/local/apache2.2.22/conf/httpd.conf: Cannot load /usr/local/apache2.2.22/modules/libphp5.so into server: /usr/local/apache2.2.22/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
 
sestatus 查看selinux状态
setenforce 0
sed -i "s/SELINUX=enforcing/SELINX=disabled/g" /etc/selinux/config
 
echo "<?php phpinfo() ?>" >index.php
访问此页面测试php是否成功
然后测试数据的访问
 
<?php
//$link_id=mysql_connect('主机名','用户','密码');
$link_id=mysql_connect('localhost','root','123456') or mysql_error();
//$link_id=mysql_connect('localhost','test','');
if($link_id){
echo "mysql successful!";
}else{
echo mysql_error();
}
 
?>