What's new in PHP 7?


  • Applies to: Grid
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: Account Center
  • Applies to: All DV
    • Difficulty: Easy
    • Time Needed: 10
    • Tools Required: Admin/Root access and SSH

Overview 

This article highlights major changes in PHP 7 and shows you how to upgrade your server.                                      

PHP 7 is the first significant version update to PHP in several years. This means that there are several upgrades and general changes that you'll want to know about. As always, we recommend that you use the latest software versions whenever possible. This article includes instructions for upgrading to PHP 7. 

PHP 7 is much faster and, due to changes in the way errors are handled, more stable. Dynamic websites that are built using popular content management systems (CMS) like Wordpress should run more efficiently and be less likely to crash when compared to previous PHP versions.  

From the official PHP documentation:  

  • 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

IMPORTANT NOTE: The official PHP 7 documentation states that "Despite the fact that PHP 7.0 is a new major version, efforts have been made to make migration as painless as possible. This release focusses mainly on removing functionality deprecated in previous versions and improving language consistency." However, there are still backwards compatibility issues that you may encounter. Before upgrading, please review the full list of backward incompatible changes. This is less of a concern for newly provisioned servers with new sites, but could still be an issue if you intend to migrate sites that utilize older versions of PHP. One possible solution is to first test your sites or applications in a virtual environment. A well documented Vagrant PHP testing environment can be found here.

Please keep in mind that while it is possible to run multiple versions of PHP on the same server, this can result in unstable environments.  

Instructions

Upgrade PHP for Grid

Instructions for upgrading your Grid PHP version may be found in this article. PHP 7 is now available to all Grid customers.

Upgrade PHP for Plesk

These instructions will walk you through the Plesk PHP upgrade process. These instructions are also available here.

Upgrade PHP for Plesk using the admin panel

1. Log into the Plesk admin panel and select Tools & Settings from the options on the left.

 

2. Select Updates and Upgrades from the Plesk column. 

3. Select Add/Remove Components

4. Use the + next to Web hosting to expand the column, then do the same for PHP interpreter versions. Change PHP 7.0 to install and click continue. 

The Plesk installer should run. Once complete, PHP 7 will be available for any of your domains. 

Note: You do not necessarily need to remove previous versions of PHP. Doing so may cause conflict with various native Plesk applications such as Horde. 

Upgrade PHP for Plesk using SSH

 Upgrading PHP for Plesk using SSH is very simple, but is not fully supported. Please consider using the Plesk admin panel to update your PHP versions, as that method is the least likely to cause issues. 

1. SSH to your server as root and execute the following:

    plesk sbin autoinstaller --select-product-id plesk --select-release-current  --install-component php7.0


2. Once complete, verify the update by executing php -v or by logging into the Plesk admin panel and navigating to tools & settings >> PHP Settings.

Upgrade PHP for cPanel

Instructions for upgrading PHP on cPanel via EasyApache 4 may be found here.

cPanel supports PHP 7 via EasyApache 4 only. You must use EasyApache 4 if you plan to use PHP 7 with your cPanel install. 

Upgrade PHP for VPS/Dedicated

These instructions are for VPS or dedicated servers that are running a common LAMP stack using CentOS or RHEL. These instructions are not supported by MediaTemple and could change at any time. As always, please make sure you have created recent backups before proceeding. 

Do not use these instructions if you use Plesk or cPanel to manage your server. It will break your server.

Centos 7.X 

SSH to your server and execute the following in order:

sudo yum -y update
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 sudo yum install -y php70w php70w-opcache

Centos 6.X

SSH to your server and execute the following in order:

sudo yum -y update

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

yum install -y php70w php70w-opcache

Once complete, verify that your version is correct and working properly by creating a PHP info page. If you need help, instructions can be found in this article