A step by step guide on how to install PHP 7 (stable) on VestaCP, the Ubuntu version plus few test results showing how its performance. I posted the CentOS version of this tutorial which you can read short introduction of PHP7 and should you use it with Vesta control panel for production website or not. But the shortest words I have to say: You better think twice before switching to PHP 7 in production especially if you still don’t know whether your app(s) is PHP7-compatible already or not. However, WordPress users do not need to worry about compatibility issue because the core CMS itself has been claimed to be PHP7-compatible. But still, As with most major-version language releases, there is still no guarantee that the WordPress theme and plugins you use are compatible. Take your time following this guide to perform some tests before you are going to production.
While its CentOS version Vestacp is using PHP 5.4.x by default, in its Ubuntu version you can see it is using PHP 5.6.x. So in this guide you’ll see how to upgrade PHP 5.6 to PHP 7.0 and how to make it work with Vestacp. You can also follow the same steps even you are not Vestacp users.
What you may need
- A SSH client like Bitvise or Putty and basic knowledge about how to use it.
- Basic knowledge about common Unix command to SSH to your server.
- A server or VPS with at least 1GB of RAM (2GB or more is recommended).
- Make sure your Vestacp server is installed and running on Ubuntu server.
- About 30 minutes of your time
- a cup of coffee or tea.
How to Install
p.s: Please click any image you wish to see its larger version.
p.p.s: I run each command as root, non root user need to add sudo prefix.
Step 1 – Install VestaCP on your vps, cloud or dedicated server. You can follow the step by step tutorial posted previously. Despite this tutorial done on Ubuntu 15.10 x64, but the steps are pretty much similar.
Step 2 – Once installed, still in Putty, you can do initial check of what PHP version is installed:
You’ll see something similar to this:
See? It is currently running PHP 5.6.11 with Zend Engine v2.6.0
Step 3 – Now you will need to firstly remove the old PHP and some of its unused items:
apt-get -y purge php5
Step 4 – Next, issue this command before you add third-party PPA:
apt-get install python-software-properties
Step 5 – Next, you need to add this third-party PPA (Personal Package Archive) from Ondřej Surý, the one who maintains the PHP packages for Debian, and offers a PPA for PHP 7.0 on Ubuntu. Because PHP7 is not yet available in default Ubuntu’s repo, Ondrej’s PPA helps us in this situation. PPAs allow third-party developers to build and distribute packages for Ubuntu outside of the official channels.
add-apt-repository ppa:ondrej/php-7.0 apt-get update
Step 6 – Then finally you can install PHP7 using apt-get:
apt-get install -y php7.0
once done, you’ll see something similar to this:
Step 7 – Installed! Now you can check it agaib using php -v command:
Voila! it is PHP 7.0.1 with Zend Engine v3.0.0
Step 8 – To make sure your app (WordPress) can run smoothly, there are some other PHP modules you have to install. Use command below to view all available php7 modules:
apt-cache search php7-*
Now install some of it you may think it is necessary:
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
Once done, you’ll see something like this
Step 9 – Do not forget to also start php-fpm service, the new one:
service php7.0-fpm start
Step 10 – Delete the old php symblink and create a new one:
rm /usr/bin/php ln -s /usr/bin/php7.0 /usr/bin/php
Step 11 – Finally, restart Apache webserver:
service apache2 restart
You can create simple phpinfo() page to see some detailed specs:
You can watch all steps above in my video to make sure you understand and be confident in following the steps.
What’s in the video:
- How to create CentOS 7 cloud server in Digital Ocean
- How to install Vestacp
- Some basic Vestacp configuration
- How to upgrade PHP to PHP 70 latest stable build.
- How to create database
- How to install WordPress
- PHP 7 + Vestacp performance test
Download the videos:
PHP 7.0 Performance Test
I installed Vestacp + PHP 7.0 in a sub directory, installed WordPress (v4.4) using Twenty Sixteen theme, and uploaded a full of dummy content on it (dummy content credits to WPTest.io). I used Digital Ocean droplet with 1GB of RAM + 1 processor core running Ubuntu 15.10 x64. The test done using free account of several server speed test services including Loader.io and LoadImpact.com.
GTMetrix Performance Test
Page speed score and Page load time are better than its CentOS version.
Pingdom Speed Test
Load time is much faster than its CentOS version, less than 1 second.
Test #1 – Clients per second test model with 10 clients per second over 1 minute duration (or equal with 864,000 unique visitors per day):
Result: The server can operate and serve request normally at that level of test while average response time is 968 ms with 167 ms minimal and 2349 ms max. There is no 500 server error code. Again, I don’t know why but it is faster than its CentOS version.
Test #1 – 50 unique users for 5 minutes duration (equal with 14,400 UV/day):
Result: LoadImpact count page load time not response time. The slowest load time is around 300 ms while the fastest one is 124 ms. As from the chart above, it’s always below 200 ms.
PHP7 is the most anticipated release version of PHP which is said much faster than PHP 5.x. In some benchmark tests PHP7 is proven almost as fast as HHVM. If my test above was correct, using Vestacp + PHP7 on Ubuntu VPS with 1GB of RAM, it can handle around 800k UV/day if you run a WordPress blog with WP Super Cache installed. However, real live result may vary.