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.
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
These instructions will walk you through the cPanel PHP upgrade process using EasyApache. These instructions are also available here.
As of right now, there is no native support for PHP 7 on cPanel. The following steps are for changing your PHP version and will work once PHP 7 is available.
1. Log into WHM and select the Software panel.
2. Select either EasyApache 3 or 4. If you are unsure, you probably need to use EasyApache 3. Don't worry if you select the wrong version. You'll receive an error letting you know that another version is currently active and will need to be used.
3. You should now see a list of available Apache profiles. From here it is easy to manage various aspects of your Apache build. To change your PHP version, select the to the right of your default profile.
4. Select Next Step to move to the PHP version menu. Select the version that you'd like to install and proceed through the remaining menus.
Important: It is very important to allow the EasyApache build process to complete. A premature termination will very likely result in a total failure of cPanel, and you will have to restore from a backup.
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.
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
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.