Install php7 on centos7

There are a couple of different ways to install php7 on centos7 – Installing yum-plugin-replace and inline-replaceing the whole php subsystem seems to be the easiest way:

You need to have a couple or yum repo’s enabled for this to work properly: webtactic and epel


rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

If you already have the repo’s installed, then you can:


yum install yum-plugin-replace

You can now install php70w from webtactic by replacing php-common.

Install php7 on centos7

I have php 5.6 installed from the webtactic repo, to upgrade I entered the following command:


yum replace php56w-common --replace-with=php70w-common

You may have the default centos php version installed, in that case, enter the following:


yum replace php-common --replace-with=php70w-common

THIS PART MAY HOSE YOUR SYSTEM

You’ll get a message about missing packages (these are files that wont be upgraded to the php7 versions because you dont have their current version installed). You have to press ‘Y’ to accept and continue to install php7 on centos7.

There are different runtime versions for php, you can install as needed:
mod_php NTS
(non-thread safety) Contained in the php70w package, this SAPI integrates into Apache Httpd (2.2.* on RHEL/CentOS 6, 2.4.* on RHEL/CentOS 7). It is the standard SAPI for use with httpd prefork mpm (the default mode httpd is ran under. It is not thread-safe, but doesn’t need to be due to prefork not using threads. It’s located at /usr/lib[64]/httpd/modules/libphp7.so
cli
Contained in the php70w-cli package, this SAPI allows running scripts from the command-line, and also has a built-in web server for development-use. Located at /usr/bin/php
fpm
Contained in the php70w-fpm package, fpm (FastCGI Process Manager) is a scalable FastCGI process, which acts similar to how Httpd prefork mpm works managing it’s forks. Located at /usr/sbin/php-fpm, it is controlled using the /etc/init.d/php-fpm service script
phpdbg
Contained in the php70w-phpdbg package, phpdbg has the ability to debug scripts using breakpoints from the command-line, and also supports remote-debugging using an external Java client for remote communication.
embedded
Contained in the php70w-embedded package, this SAPI allows embedding PHP in other applications. It’s library is located at /usr/lib[64]/libphp7.so
cgi, fastcgi
Contained in the php70w-cli package, these SAPIs are not recommended for use, but are available where needed. They both exist in the binary at /usr/bin/php-cgi.
mod_php TS
(thread safety) Contained in the php70w package, this SAPI integrates into Apache Httpd (2.2.* on RHEL/CentOS 6, 2.4.* on RHEL/CentOS 7). It is the standard SAPI for use with httpd worker mpm. It’s supposed to be thread-safe, but can’t guarantee to be, and certainly not under additional PHP extensions. It’s better to use FastCGI SAPIs than this one. It’s located at /usr/lib[64]/httpd/modules/libphp7-zts.so

Leave a Reply