一、安装相关的依赖:
yum -y install gcc gcc-c++ bzip2-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel
二、解压php安装包php-5.6.22.tar.gz
tar -xzvf php-5.6..tar.gz -C/usr/src/
三、编译安装php
cd /usr/src/php-5.6./
./configure --prefix=/usr/local/php5.6/ --with-config-file-path=/usr/local/php5.6/etc --with-config-file-scan-dir=/usr/local/php5.6/etc/php.d --with-mysql=/usr/local/mysql/ --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --enable-bcmath --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/httpd/bin/apxs --with-bz2 --enable-maintainer-zts --with-gd --with-gettext && make && make install
四、查看模块的php是否安装成了httpd的模块
ll /usr/local/httpd/modules/ | grep --color php
五、复制php的配置文件
cp /usr/src/php-5.6./php.ini-production /usr/local/php5.6/etc/php.ini
六、修改httpd的配置文件使httpd能处理php文件
vim /usr/local/httpd/conf/httpd.conf
增加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps 修改
DirectoryIndex index.php index.html
七、制做一个首页文件index.php用于测试php是否安装成功
mv /usr/local/httpd/htdocs/index.html /usr/local/httpd/htdocs/index.php vim /usr/local/httpd/htdocs/index.php
<html>
<head>
</head>
<body>
<?php
phpinfo();
?>
</body>
</html>
八、启动httpd并查看php页面是否生效