Page 1 of 11

HOWTO: Install PHP7.0 or PHP 7.2 on CentOS 7

Posted: Fri Aug 05, 2016 1:43 pm
by SS88
Note: This is only for NGINX + PHP-FPM VestaCP installs.

PHP 7.2 install is located here: viewtopic.php?f=11&t=12319&p=68007#p68007

BELOW IS PHP 7.0 INSTALL!

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

[root@tiny 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

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Sat Sep 03, 2016 10:36 pm
by edica
This command also remove roundcubemail.

yum -y remove php

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Tue Sep 06, 2016 11:54 pm
by SS88
edica wrote:This command also remove roundcubemail.

yum -y remove php
I just did fresh install today on CentOS 7.2 and it did not remove Roundcube.

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Wed Sep 07, 2016 2:11 pm
by edica
Remove roundcubemail as dependency.

Image

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Sat Sep 10, 2016 8:53 am
by anonymous.it.2016
Perfect. i have done

thank you very much!

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Wed Sep 21, 2016 1:46 am
by duy13
This command will remove roundcubemail.

Code: Select all

yum -y remove php




Please use this:

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

yum -y --enablerepo=remi-php70 upgrade php

yum -y --enablerepo=remi install roundcubemail #(will upgrade roundcubemail to 1.2)

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

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Tue Sep 27, 2016 10:56 am
by baijianpeng
duy13 wrote: Please use this:

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

yum -y --enablerepo=remi-php70 upgrade php

yum -y --enablerepo=remi install roundcubemail #(will upgrade roundcubemail to 1.2)

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

hi, duy13,

I used your code, but I got following result:

Code: Select all

# php -v
PHP 7.0.11 (cli) (built: Sep 14 2016 08:28:52) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
These is no "with Zend OPcache v7.0.9" in my installation. Why?

Do I need to install OPcache separately?

Thank you.

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Wed Sep 28, 2016 2:25 pm
by baijianpeng
edica wrote:Remove roundcubemail as dependency.

Image
hi, @edica,

You are right. When I following the topic author's steps, the "yum -y remove php" command will remove roundcubemail as dependency.

When I tried to re-install roundcubemail , it can not be done.

Why?

How to restore roundcubemail now?

Is it possible to upgrade to PHP7 WITHOUT losing roundcubemail ?

Thank you.

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Sun Oct 09, 2016 2:27 pm
by SS88
baijianpeng wrote:
edica wrote:Remove roundcubemail as dependency.

Image
hi, @edica,

You are right. When I following the topic author's steps, the "yum -y remove php" command will remove roundcubemail as dependency.

When I tried to re-install roundcubemail , it can not be done.

Why?

How to restore roundcubemail now?

Is it possible to upgrade to PHP7 WITHOUT losing roundcubemail ?

Thank you.
I don't know if you have done this but I updated the commands and removed "yum -y remove php" and now everything works as expected.

Re: HOWTO: Install PHP7 on CentOS 7

Posted: Wed Oct 12, 2016 10:56 am
by baijianpeng
SS88 wrote: I don't know if you have done this but I updated the commands and removed "yum -y remove php" and now everything works as expected.
Today I tried your above steps again, when I run the following command, I got error:

Code: Select all

# service php-fpm stop
Redirecting to /bin/systemctl stop  php-fpm.service
Failed to stop php-fpm.service: Unit php-fpm.service not loaded.
Did I missed something?

Thank you.

PS: I think, "service ..." is a command on CentOS 6.x, right? On CentOS 7, you should use "systemctl ... ", right? Why you still use "service ... " command on CentOS7?