在文章中,咱們將展現在centOS系統下若是將php升級到5.6,以前經過yum來安裝lamp環境,直接升級的話,提示沒有更新包,也就是說默認狀況下php5.3.3是最新php
1.查看已經安裝的php版本號mysql
鍵入下面代碼:c++
php -v 或者 /usr/bin/php
出現下面代碼: sql
PHP 5.3.3 (cli) (built: Jul 9 2015 17:39:00) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
2.安裝Remi跟EPEL RPM源vim
下載並安裝,代碼以下: curl
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm
下載以後:post
vim /etc/yum.repos.d/remi.repo
而後對裏面內容進行如下修改:flex
[remi] name=Remi's RPM repository for Enterprise Linux 6 - $basearch #baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/ mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
還有如下:ui
[remi-php56] name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch #baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/ mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror # WARNING: If you enable this repository, you must also enable "remi" enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
3.如今能夠yum命令直接升級了this
輸入如下代碼
yum -y upgrade php*
大概是鏡像問題。我獲得了報錯
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://rpms.remirepo.net/enterprise/6/php55/mirror error was
12: Timeout on http://rpms.remirepo.net/enterprise/6/php55/mirror: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
錯誤:Cannot find a valid baseurl for repo: remi-php55
而後我yum update -y php*就行了 -_-無奈!
一旦更新完畢,再次查看php版本號
php -v
出現如下信息
PHP 5.6.30 (cli) (built: Jan 19 2017 08:09:42) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
一鍵安裝擴展
yum -y install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel mysql-devel net-snmp-devel curl-devel perl-DBI mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-bcmath php-mbstring
到此,php升級完畢