1、参考此文章的前提是你已经安装了mysql、apache,如果没有安装,可以参考我的这两个博客,然后在安装php,有个先后顺序关系
mysql源码安装
https://blog.csdn.net/weixin_42151614/article/details/82497706
apache源码安装
https://blog.csdn.net/weixin_42151614/article/details/82498115
1、准备工作,解决依赖关系
yum -y install epel-release
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel ibpng libpng-devel freetype freetype-devel libjpeg-devel libmcrypt libmcrypt-devel
2、进入到/usr/local/src目录下
cd /usr/local/src
3、下载PHP5.6
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
4、解压
tar zxvf php-5.6.30.tar.gz
cd php-5.6.30
5、编译参数
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
6、编译安装
make && make install
7、拷贝配置文件
cp php.ini-production /usr/local/php/etc/php.ini
8、查看php加载的模块
/usr/local/php/bin/php -m