Recommended VPS Complete list of best VPS hosting providers.

Install PHP 7 on CentOS, Ubuntu and Debian

install php 7 tutorial

So PHP 7 is out on December 3 2015 and yet, it has also been updated to PHP 7.0.1 on December 17 2015 bringing not just advanced features and tweaked performance but also several bugs has been fixed. Its developers made #php7 as a major release version which has been long anticipated by many php fans. You probably wondering of why is it PHP 7 and not PHP 6? Where is the v6 of PHP? For your information, PHP 6 already existed in the past as an experimental project but sadly it never reached the production phase. Hence the developers named the new major release will as PHP 7 to prevent users from mixing up the former attempt with the latest development. There are many new things about PHP 7 but the most highlighted features are its light performance and speedy php processing. Yet, many say its performance is as fast as HHVM.

Also read:
10 things you need to know about PHP 7
10 things not to do in PHP 7

PHP 7.0.0 comes with a new version of the Zend Engine, numerous improvements and new features such as

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6
  • Significantly reduced memory usage
  • Abstract Syntax Tree
  • Consistent 64-bit support
  • Improved Exception hierarchy
  • Many fatal errors converted to Exceptions
  • Secure random number generator
  • Removed old and unsupported SAPIs and extensions
  • The null coalescing operator (??)
  • Return and Scalar Type Declarations
  • Anonymous Classes
  • Zero cost asserts

How to install PHP 7 – or upgrade to PHP7

In this page you’ll see basic method explained in a video guide about how to install PHP 7 on either CentOS, Ubuntu or Debian server. You can try it on your VPS, Cloud server or even Dedicated server.

Also read:
How to update Vestacp to PHP 7 on CentOS
How to update Vestacp to PHP 7 on Ubuntu

Install PHP 7 on CentOS / RHEL

Installing PHP in CentOS can be done easily using Yum so you don’t have to compile it from sources. That way it can be done easier and safer, especially for newbies. There currently two methods you can choose one of it to follow:

1. Using Webtatic Repo

Step 1 – Login to your CentOS server as root or as a user with sudo privilege.

Step 2 – Do yum update to make sure all packages are up to date:

yum update -y

Step 3 – Install Apache 2 web server (httpd):

yum install httpd -y

Step 4 – Add webtatic repository in your CentOS 7.x:

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

However if you are still using CentOS 6.x, then use this instead:

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

Step 5 – Now finally you can install PHP 7 using command below:

yum install php70w

Step 6 – You may also need to install several common PHP 7 modules. List it using command below:

yum search php70w-

Need a shortcut? Here’s the command to install PHP modules which are usually needed by many apps:

yum install php70w-cli php70w-common php70w-bcmath php70w-dba php70w-devel php70w-embedded php70w-fpm php70w-gd php70w-imap php70w-interbase php70w-intl php70w-ldap php70w-mbstring php70w-mcrypt php70w-mysql php70w-odbc php70w-opcache php70w-pdo php70w-pdo_dblib php70w-pear php70w-process php70w-pspell php70w-recode php70w-tidy php70w-xml php70w-xmlrpc

2. Using Remi repo

Step 1 – Login to your CentOS server as root or as a user with sudo privilege.

Step 2 – Do yum update to make sure all packages are up to date:

yum update -y

Step 3 – Install Apache 2 web server (httpd):

yum install httpd -y

Step 4 – Add EPEL and Remi repository in your CentOS 7.x:

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

However if you are still using CentOS 6.x, then use this instead:

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

Step 5 – Then now update your yum repo list

yum --enablerepo=remi update remi-release

Step 6 – Now finally you can install PHP 7 using command below:

yum --enablerepo=remi-php70 install php70

Step 7 – You may also need to install several common PHP 7 modules. List it using command below :

yum --enablerepo=remi-php70 search php70-

Need a shortcut? Here’s the command to install PHP modules which are usually needed by many apps:

yum --enablerepo=remi-php70 install php70w-cli php70w-common php70w-bcmath php70w-dba php70w-devel php70w-embedded php70w-fpm php70w-gd php70w-imap php70w-interbase php70w-intl php70w-ldap php70w-mbstring php70w-mcrypt php70w-mysql php70w-odbc php70w-opcache php70w-pdo php70w-pdo_dblib php70w-pear php70w-process php70w-pspell php70w-recode php70w-tidy php70w-xml php70w-xmlrpc

Now you can verify it using php -v command:

php-701-centos

See? It is PHP 7.0.1 with Zend Engine v3.0.0 and Zend OPcache v7.0.6-dev. How cool is that?

Install PHP 7 on Ubuntu

Currently there is one known PPA (Personal Package Archive) that provides ready-to-install PHP 7: the Ondrej Sury’s PPA which is maintained by Ondřej Surý. Follow these steps to install it on either Ubuntu 14.04, Ubuntu 15.04 or Ubuntu 15.10:

Step 1 – Login to your Ubuntu server as root or as a user with sudo privilege.

Step 2 – Do apt-get update to make sure all packages are up to date:

apt-get update -y

Step 3 – Install Apache 2 web server :

apt-get install apache2 -y

Step 4 – Add Ondrej PPA and do apt-get update again:

add-apt-repository ppa:ondrej/php-7.0
apt-get update

Step 5 – Now finally you can install PHP 7 using command below :

apt-get install php7.0 -y

Step 6 – You may also need to install several common PHP 7 modules. List it using command below :

apt-cache search php7.0-

Need a shortcut? Here’s the command to install PHP modules which are usually needed by many apps:

apt-get install php7.0-common libapache2-mod-php7.0 php7.0-cgi php7.0-cli php7.0-phpdbg php7.0-fpm libphp7.0-embed php7.0-dev php7.0-dbg php7.0-curl php7.0-gd php7.0-imap php7.0-interbase php7.0-intl php7.0-ldap php7.0-mcrypt php7.0-readline php7.0-odbc php7.0-pgsql php7.0-pspell php7.0-recode php7.0-tidy php7.0-xmlrpc php7.0 php7.0-json php-all-dev php7.0-sybase php7.0-modules-source php7.0-sqlite3 php7.0-mysql php7.0-opcache php7.0-bz2

Finally, verify it using php -v command:

php-701-ubuntu

It is also PHP 7.0.1 with the same Zend OPCache version. Cool!

Install PHP 7 on Debian

PHP 7 can be installed using apt-get on Debian by simply adding a nice repository source from Dotdeb.org. Simply follow steps below to install PHP 7 on Debian 8:

Step 1 – Login to your Ubuntu server as root or as a user with sudo privilege.

Step 2 – Do apt-get update to make sure all packages are up to date:

apt-get update -y

Step 3 – Install Apache 2 web server :

apt-get install apache2 -y

Step 4 – Edit apt source list by adding new repo URL. You can use any of your favorite editor like Nano or vi.

nano /etc/apt/sources.list

then add these lines in it:

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

Step 5 – You have to also then add the GPG key:

wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg

Step 6 – Do apt-get update again and install PHP 7 with command below:

apt-get update
apt-get install php7.0

Do not forget to verify the PHP version using simple php -v command:

php-701-debian

Step 7 – You may also need to install several common PHP 7 modules. List it using command below :

apt-cache search php7.0-

Need a shortcut? Here’s the command to install PHP modules which are usually needed by many apps:

apt-get install libphp7.0-embed php-all-dev php7.0-bz2 php7.0-cgi php7.0-cli php7.0-common php7.0-curl php7.0-dbg php7.0-dev php7.0-fpm php7.0-gd php7.0-imap php7.0-interbase php7.0-intl php7.0-json php7.0-ldap php7.0-mcrypt php7.0-mysql php7.0-odbc php7.0-opcache php7.0-pgsql php7.0-phpdbg php7.0-pspell php7.0-readline  php7.0-recode php7.0-sqlite3 php7.0-sybase php7.0-tidy php7.0-xmlrpc

That’s it and done!

The Video Guide

Wait wait..! So where are the usual screenshot pics of every steps? Relax bro and sist! I don’t included screenshot pics by purpose but I recorded all steps above plus some additional steps in a video so you can watch it and follow the steps confidently.

What’s in the video?

install php 7 videos files

You can see in the video all the steps about installing PHP 7 (as above) and how to upgrade from older version of PHP like 5.3, 5.4 or 5.6. How to properly remove old php version and replace it with its version 7. There are 6 videos you can download. Total size of the video is approx 437 MB in .mkv format.

Download the videos for only $2.99 but wait! Use coupon code BUDGETVMCOM to get 100% discount.

Download Here

Sponsor :

This article is exclusively sponsored by BudgetVM.com, a US Dedicated Servers provider which also provides Asia optimized DDOS protected dedicated servers in LA along with VPS and Cloud servers.

5 Comments

Add a Comment

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

Get more stuff like this
in your inbox

Subscribe and get interesting stuff plus faster updates to your email.