关于CentOS6.x/6.5/6.4/6.3/6.2/7.x 64位安装php5.2的方法详解

默认情况下,CentOS6 64 bit 已经早已不支持php5.2.x ,但是某些php程序还需要zend optimizer支持,怎么办呢?目前大部分的yum repos 都已经不支持直接安装php5.2了,怎么在CentOS6.x/6.5/6.4/6.3/6.2/7.x 64位安装php5.2(使用YUM自动安装)。

wget -qq -O - http://www.atomicorp.com/installers/atomic | /bin/bash

备份[ !!! Take php.ini, php.conf and other backups !!! ],如果是新安装的,就忽略此部分。

删除已经安装的php包 yum remove php*

安装 yum install atomic-php52*

做好映射:

  1. ln -s /opt/atomic/atomic-php52/root/usr/bin/php /usr/bin/php
  2. ln -s /opt/atomic/atomic-php52/root/usr/bin/php-cgi /usr/bin/php-cgi
  3. ln -s /opt/atomic/atomic-php52/root/etc/php.d/ /etc/php.d
  4. ln -s /opt/atomic/atomic-php52/root/etc/php.ini /etc/php.ini
  5. ln -s /opt/atomic/atomic-php52/root/usr/lib64/php/ /usr/lib64/php
  6. ln -s /opt/atomic/atomic-php52/root/usr/share/php/ /usr/share/php
  7. vi /etc/httpd/conf.d/atomic-php52-php.conf
  8. # Edit prefork part from libphp5.so to libphp52.so:
  9. LoadModule php5_module modules/libphp52.so

测试:

  1. # php -v
  2. PHP 5.2.17 (cli) (built: May 21 2014 09:58:58)
  3. Copyright (c) 1997-2010 The PHP Group
  4. Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
  5. # uname -a
  6. Linux host819.ctohome.com 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
  7. [root@host819 etc]# cat /etc/redhat-release
  8. CentOS release 6.5 (Final)

搞定!!

收尾:

service httpd restart

vi /etc/yum.conf

增加 exclude=php* 防止不小心升级了php

在安装zend optimizer即可:

  1. This program makes use of the Zend Scripting Language Engine:
  2. Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
  3. with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
  4. with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

如果你需要我们帮您安装php5.2 + Zend Optimizer ,费用是100元/服务器/次安装

centos5.x 32bit 默认安装是php5.1.x 版本, 要升级到php5.2可尝试如下方法:

  1. cd /tmp;
  2. rpm -ivh http://software.virtualmin.com/bleed/centos/5/i386/virtualmin-bleed-release-1.0-1.rhel.noarch.rpm
  3. rm -f php*

vi /etc/yum.conf 增加下面一行禁止升级php5.3

exclude=php*5.3*

执行下面命令开始升级php,检查是否显示的是php5.2的版本

yum update php*

vi /etc/yum.conf 增加下面一行禁止升级php

exclude=php*5.3* php*

centos5.x 32bit安装php5.2的另一个方法:

rpm -Uvh http://mirror.webtatic.com/yum/centos/5/latest.rpm

rm -f php*

vi /etc/yum.conf 增加下面一行禁止升级php5.3

exclude=php*5.3*

执行下面命令开始升级php,检查是否显示的是php5.2的版本

yum --enablerepo=webtatic --exclude=php*5.3* update php*

安装缺失php库:

yum --enablerepo=webtatic --exclude=php*5.3* install mcrypt mbstring php-mbstring php-mcrypt

升级成功后,

vi /etc/yum.conf 增加下面一行禁止升级php

exclude=php*5.3* php*