Upgrade PHP 5.6 to PHP 7 on Nginx / Debian Jessie

With recent updates, WordPress has increased it server requirement from PHP 5.6 to PHP 7. I think it is the best time to upgrade PHP to follow the requirement. FYI, Most of my servers are running based on Debian Jessie.

Uninstall old PHP

If your server freshly installed, jump to next step.

I prefer to uninstall old PHP as most of my sites are running WordPress.

List all PHP packages installed:

you will see the list of packages related to PHP, if you sure to do this let’s go on to removal process:

Install PHP7

Add repository:

Install GnuPG key:

Update local package:

Install PHP7:

Install PHP7-MySQL:

Configuring Nginx Server Block

Next part is to configuring Nginx server block, the config file(s) location may vary depending on admin’s preferences.

Comment old config or delete it, add new path module:

Restart Nginx:

Start PHP7-FPM:

Test:

or, add this to a blank .php file:

then access it using your web browser. And try to run your WordPress website now.

Impressions

I feel that sites are under PHP 7 significantly runs faster. I didn’t do a measured test but, here the benchmark PHP 7 vs previous versions.

Update

(27/02/17)
You might need to install php-gd to enable image resizing for WordPress:

(20/04/17)
These PHP module packages also required:

 

How To, Linux, PHP, Software, Update

Leave a Reply