HOWTO: Install PHP7 on CentOS 7 Topic is solved

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
SS88
Posts: 298
Joined: Thu Nov 19, 2015 12:40 pm

HOWTO: Install PHP7 on CentOS 7  Topic is solved

Postby SS88 » Fri Aug 05, 2016 1:43 pm

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
Last edited by SS88 on Tue Oct 04, 2016 10:19 pm, edited 1 time in total.

edica
Posts: 101
Joined: Tue May 26, 2015 7:31 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby edica » Sat Sep 03, 2016 10:36 pm

This command also remove roundcubemail.

yum -y remove php

SS88
Posts: 298
Joined: Thu Nov 19, 2015 12:40 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby SS88 » Tue Sep 06, 2016 11:54 pm

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.

edica
Posts: 101
Joined: Tue May 26, 2015 7:31 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby edica » Wed Sep 07, 2016 2:11 pm

Remove roundcubemail as dependency.

Image

anonymous.it.2016
Posts: 1
Joined: Sat Sep 10, 2016 8:48 am

Re: HOWTO: Install PHP7 on CentOS 7

Postby anonymous.it.2016 » Sat Sep 10, 2016 8:53 am

Perfect. i have done

thank you very much!

duy13
Posts: 11
Joined: Wed Jul 06, 2016 2:53 am

Re: HOWTO: Install PHP7 on CentOS 7

Postby duy13 » Wed Sep 21, 2016 1:46 am

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

baijianpeng
Posts: 289
Joined: Tue Dec 22, 2015 2:06 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby baijianpeng » Tue Sep 27, 2016 10:56 am

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.

baijianpeng
Posts: 289
Joined: Tue Dec 22, 2015 2:06 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby baijianpeng » Wed Sep 28, 2016 2:25 pm

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.

SS88
Posts: 298
Joined: Thu Nov 19, 2015 12:40 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby SS88 » Sun Oct 09, 2016 2:27 pm

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.

baijianpeng
Posts: 289
Joined: Tue Dec 22, 2015 2:06 pm

Re: HOWTO: Install PHP7 on CentOS 7

Postby baijianpeng » Wed Oct 12, 2016 10:56 am

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?


Return to “Web Server”



Who is online

Users browsing this forum: No registered users and 9 guests