UPGRADE FROM PHP 5.6 TO PHP 7.1 ON CENTOS 7

check out the current php version, we have PHP 5.6.30
$ php -version

PHP 5.6.30 (cli) (built: Jan 19 2017 22:31:39)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans

Let’s first install peel and web static repository
$ sudo yum install epel-release
$ sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

let’s update yum
$ sudo yum update

in case backup the current configuration files manually (it will be automatically saved when removing the files, so you can skip this if you want)
$ sudo cp /etc/php.ini /etc/php.ini.bak
$ sudo cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.bak
$ sudo cp /etc/php.d/opcache.ini /etc/php.d/opcache.ini.bak
$ sudo cp /etc/php.d/z-memcached.ini /etc/php.d/z-memached.ini.bak

it will show you a list of both php70 and php71
$ sudo yum search php7

you can also verify that mod_php71w exists
$ sudo yum search mod_php7

remove old php5.6
$ sudo yum remove php56w php56w-cli php56w-common php56w-fpm php56w-gd php56w-mbstring php56w-mysqlnd php56w-opcache php56w-pdo php56w-pear php56w-pecl-igbinary php56w-pecl-memcache php56w-pecl-memcached php56w-process php56w-xml

it saves the configuration files for you!

warning: /etc/php-fpm.d/www.conf saved as /etc/php-fpm.d/www.conf.rpmsave

warning: /etc/php.d/z-memcached.ini saved as /etc/php.d/z-memcached.ini.rpmsave

warning: /etc/php.ini saved as /etc/php.ini.rpmsave

Let’s install PHP7.1
$ sudo yum install php71w-bcmath php71w-cli mod_php71w php71w-common php71w-dba php71w-devel php71w-embedded php71w-enchant php71w-fpm php71w-gd php71w-imap php71w-interbase php71w-intl php71w-ldap php71w-mbstring php71w-mcrypt php71w-mysqlnd php71w-odbc php71w-opcache php71w-pdo php71w-pdo_dblib php71w-pear php71w-pecl-apcu php71w-pecl-apcu-devel php71w-pecl-geoip php71w-pecl-igbinary php71w-pecl-igbinary-devel php71w-pecl-imagick php71w-pecl-imagick-devel php71w-pecl-libsodium php71w-pecl-memcached php71w-pecl-mongodb php71w-pecl-redis php71w-pecl-xdebug php71w-pgsql php71w-phpdbg php71w-process php71w-pspell php71w-recode php71w-snmp php71w-soap php71w-tidy php71w-xml php71w-xmlrpc

NOTE: if necessary replace php-common with php71w-common but I didn’t need that!
$ sudo yum install yum-plugin-replace
$ sudo yum replace php-common --replace-with=php71w-common

check if php 7.1 installed
$ php -version

PHP 7.1.6 (cli) (built: Jun 10 2017 07:28:42) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.6, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans

replace the new configuration files with the saved configuration files (opcache is retrieved from manual backup)
$ sudo mv /etc/php.ini.rpmsave /etc/php.ini
$ sudo mv /etc/php-fpm.d/www.conf.rpmsave /etc/php-fpm.d/www.conf
$ sudo mv /etc/php.d/z-memcached.ini.rpmsave /etc/php.d/z-memcached.ini
$ sudo mv /etc/php.d/opcache.ini.bak /etc/php.d/opcache.ini

LET’S CHECK BASIC PHP EXTENSIONS

verify iconv
$ php -i | grep -i "iconv support"

iconv support => enabled

verify curl
$ curl -V

curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.21 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets

list PHP modules
$ php -m

[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
enchant
exif
fileinfo
filter
ftp
gd
geoip
gettext
gmp
hash
iconv
igbinary
imagick
imap
interbase
intl
json
ldap
libsodium
libxml
mbstring
mcrypt
memcached
mongodb
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
PDO_Firebird
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
recode
redis
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

YEYYYYY!!!

Advertisements

2 thoughts on “UPGRADE FROM PHP 5.6 TO PHP 7.1 ON CENTOS 7

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s