VestaCP HOWTO: Install PHP7 on CentOS 7

VestaCP HOWTO: Install PHP7 on CentOS 7

 

This tutorial REPLACES PHP 5.X COMPLETELY. Do NOT use it if you want multiple PHP versions.

If you have REMI Repository you can skip this step.

CODE: SELECT ALL

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

Then enable Remi

CODE: SELECT ALL

yum --enablerepo=remi update remi-release

Now remove old PHP and install PHP7

CODE: SELECT ALL

service php-fpm stop
yum -y --enablerepo=remi install php70-php php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring

Remove and re-link new PHP7

CODE: SELECT ALL

rm -f /usr/bin/php
ln -s /usr/bin/php70 /usr/bin/php

Test if we have PHP 7

CODE: SELECT ALL

php -v

Output should be (take note of PHP 7!!)

CODE: SELECT ALL

[[email protected] system]# php -v
PHP 7.0.9 (cli) (built: Jul 20 2016 16:58:48) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies

Now open up new PHP-FPM.conf ( /etc/opt/remi/php70/php-fpm.conf ) file and change line 11 to:

CODE: SELECT ALL

include=/etc/php-fpm.d/*.conf

Start PHP-FPM

CODE: SELECT ALL

service php70-php-fpm start

Remove old systemctl php-fpm and link to new one

CODE: SELECT ALL

rm -f /usr/lib/systemd/system/php-fpm.service
ln -s /usr/lib/systemd/system/php70-php-fpm.service /usr/lib/systemd/system/php-fpm.service

Reload systemctl daemon

CODE: SELECT ALL

systemctl daemon-reload

Restart web service (i use nginx)

CODE: SELECT ALL

service nginx restart

https://forum.vestacp.com/viewtopic.php?t=12319

Leave a Comment

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

Shares