PHP Tutorials

Upgrade PHP Version for VPS or Dedicated Server

Being the most popular open source web development language on the planet, PHP connects HTML pages to databases and multimedia applications for creating dynamic and interactive content. No matter when it comes to web developers, web site owners, or those who are running a CMS-powered online presence, keeping update the latest version of PHP seems extremely important since most of the time new release contains many cool features in addition to higher-level performance and security.

The good news is, the feature-complete PHP 7 version was recently released, which is the first significant version update to PHP in several years. This article includes the general changes in PHP 7 and how to upgrade PHP version for your VPS or dedicated server.

What’s new in PHP 7?

  1. Twice the speed

The performance of PHP 7 is recognizably improved through the developers’ hard working in refactoring the PHP codebase for reducing memory consumption and increasing performance. Benchmarks for PHP 7 tested against WordPress show speeds twice as fast as PHP 5.6, meaning that your code will be executed much faster while fewer servers is needed to serve the same amount of users.

  1. New type declarations enabled

If you are a developer expecting for declaring the return of a function to prevent return values occurred unintendly, the new PHP 7 meets your needs perfectly, enabling you to have the quality of their code enhanced using return type declarations. Here’s a brief example of using the foo() function to return an array:

Besides that, four new scalar types have been added in PHP 7, including int, float, string, and bool. These new type declarations for scalar types enable you to denote what you want floats, integers, booleans, or strings to be returned. Meanwhile, all the new scalar types are supported by argument Type Hints, which make it possible for you to force the type of parameters since the PHP 5.x series.

  1. Facilitate error handling

Handling fatal and catchable fatal errors in the past have been next to impossible in PHP. A fatal error would stop your script but wouldn’t invoke the error handler. The most common use case is a blank white screen showed on a production server, which usually makes your users confused and hurt your credibility in the end. Even worse, it will lead to bad issues with resources that were never closed properly and are still in use or even locked.

However, the new Engine Exceptions in PHP 7 helps you replace these kinds of errors with exceptions, rather than simple stop the script. And an uncaught exception will continue to return the same fatal errors the same as it does in the current PHP 5.x series.

  1. Spaceship and Null Coalesce Operators

PHP 7 other more brings us two new operators: Spaceship Operator and Null Coalesce Operator.

Running under the name of Combined Comparison Operator, the Spaceship Operator is a nice addition to the language, using three individual operators including greater than, equal, and less than. The Spaceship Operator returns -1 if the right operand is greater, 1 if the right is less, and () if both are equal.

The Null Coalesce Operator, on the other side, is effectively the fabled if-set-or. That is, if an operand exists and isn’t null, it will return the left, otherwise it will return the right.

  1. Easy User-land CSPRNG

Typically, the application space external to the kernel and protected by privilege separation is called user-land, while CSPRNG is short for Cryptographically Secure PseudoRandom Number Generator that is generated using API in PHP.

In PHP 7, all random number generators are operated on a system interface, making the random numbers more secure without harming your entire system even when generating random passwords or password salt.

What do you need to do about the PHP upgrade?

Though your php hosting provider mostly will let you know ahead of time before your version of PHP being automatically updated, you are recommended to at least have a backup of your account just in case.

Back up your account

  • Full cPanel backups: You can visit the (cPanel > ’Files’ > ‘Full Backup’), and click the Download a Full Website Back button, select the Home Directory option in the next page, and click Generate Backup to begin the backup.
  • Full Plesk backups: Log in to the control panel as the Admin user, click on Tools & Settings, Backup Manager, Back Up buttons successively to make a new server backup.

How to upgrade your PHP version for VPS or dedicated server?

These instructions will walk you through different process of PHP upgrade for VPS or dedicated server.

Upgrade PHP using EasyApache

Understanding the way of updating PHP on your own by making use of EasyApache in WHM (Web Host Manager) is great knowledge to have if you want to keep your website PCI compliant.

  1. Log into WHM.
  2. Search for EasyApache once you have found the search field, which is located in the upper left hand corner.
  3. Click Start customizing based on profile button when scrolling down to the bottom.
  4. On the next page, click Next Step to keep the same version of Apache.
  5. You would find some versions of PHP on the next page, choose the PHP 7, and click on Next Step.
  6. If you’re looking for bring more functionality with PHP, you can enable any Apache mods or PHP extensions on the Short Options List. After this is done, scroll to the bottom and choose Save and Build.
  7. When a Confirm Action window pop-ups, click Yes to start the recompiling process.

The whole build process will take 20 minutes around, remember keep WHM open during this time.

Upgrade PHP for Plesk 12.5

Plesk is another widely-used control panel besides cPanle, and PHP 7 has just announced to be fully supported out of the box in Plesk 12.5 for both Linux and Windows operating systems.

  1. Upgrade via GUI

Visit Add/Remove Components > Web hosting features > Different PHP interpreters versions on the Plesk Installer interface, and select the PHP 7 component.

  1. Upgrade via CLI

Follow the code on Linux OS:

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

Follow the code on Windows OS:

“%plesk_bin%”\\ai.exe -select-product-id plesk –select-release-current  –install-component php70

After installation, PHP 7 will be available for selection in service plans and website hosting settings.

Leave a Reply

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