1. 程式人生 > >CentOS升級PHP(預設5.3版本,升級至5.4以上)

CentOS升級PHP(預設5.3版本,升級至5.4以上)

CentOS/RHEL 7.x:

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x:

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

CentOS/RHEL 5.x:

rpm -Uvh https://mirror.webtatic.com/yum/el5/latest.rpm

新增完yum源之後就可以直接使用yum命令安裝php5.5了:

yum installphp54w
安裝PHP5.4的memcache和redis擴充套件: yum installphp54w-pecl-memcache php54w-pecl-redis

安裝PHP5.4的其它常用擴充套件:

yum -y installphp54w-curl php54w-gd* php54w-pdo* php54w-xmlrpc php54w-xml php54w-mcrypt php54w-fpm php54w-cli php54w-cgi php54w-pear* php54w-mbstring php54w-mysql php54w-devel php54w-pecl-apc php54w-pecl-zendopcache php54w-pecl-memcache php54w-pecl-redis

yum源新增後,如果報錯

Error: xz compression not available

說明安裝了不匹配作業系統版本的yum源,如CentOS6裝了CentOS7的源,需要將不適當的源刪除掉。

安裝php-mcrypt模組報錯:

Error: Package: php55w-mcrypt-5.5.38-1.w6.x86_64 (webtatic)
           Requires: libmcrypt.so.4()(64bit)

安裝libmcrypt.so.4方法:

wget http://mirrors.hust.edu.cn/epel//6/x86_64/epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 

yum install libmcrypt-devel