CentOS/RHEL 上使用YUM安装高版本的php

由于CentOS上yum默认安装的php是5.3版本,很多较新的CMS程序不支持此版本,例如Joomla! 3只支持5.4以上的版本,所以我们需要将本机的php升级到5.4以上版本。

首先卸载本机的php:

yum remove php  php-bcmath php-cli php-common  php-devel php-fpm    php-gd php-imap
php-ldap php-mbstring php-mcrypt php-mysql   php-odbc   php-pdo   php-pear  php-pecl-igbinary
php-xml php-xmlrpc

然后添加第三方的yum源:

CentOS/RHEL 7.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

CentOS/RHEL 5.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm

注意自己的系统版本,选择对应的源进行添加。接下来就可以添加你需要版本的php了,例如php5.5:

yum install php55w php55w-opcache
你在安装的时候可能会遇到这样的问题:
Error: php55w-common conflicts with php-common-5.3.3-46.el6_7.1.x86_64
我们可以用如下方法进行解决:
yum install yum-plugin-replace
 
yum replace php-common --replace-with=php55w-common
然后再使用之前的命令安装php即可。


参考网站:https://webtatic.com/ (上面有各种centos升级php的文章)


附php package(请按自己需求进行下载安装):
Package Provides
php55w mod_php, php55w-zts
php55w-bcmath
php55w-cli php-cgi, php-pcntl, php-readline
php55w-common php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php55w-dba
php55w-devel
php55w-embedded php-embedded-devel
php55w-enchant
php55w-fpm
php55w-gd
php55w-imap
php55w-interbase php_database, php-firebird
php55w-intl
php55w-ldap
php55w-mbstring
php55w-mcrypt
php55w-mssql
php55w-mysql php-mysqli, php_database
php55w-mysqlnd php-mysqli, php_database
php55w-odbc php-pdo_odbc, php_database
php55w-opcache php55w-pecl-zendopcache
php55w-pdo
php55w-pecl-gearman
php55w-pecl-geoip
php55w-pecl-memcache
php55w-pecl-xdebug
php55w-pgsql php-pdo_pgsql, php_database
php55w-process php-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php55w-pspell
php55w-recode
php55w-snmp
php55w-soap
php55w-tidy
php55w-xml php-dom, php-domxml, php-wddx, php-xsl
php55w-xmlrpc
如果您在按照本文章的方法升级时遇到问题,请联系博主或者在下方留言,我将及时进行回复

 

About the Author

admin

Leave a Reply

Your email address will not be published. Required fields are marked *