When installing PHP on Debian 9, the default version is PHP 7.0.
This version have been declared End-of-life since January 10, 2019.
PHP 7.0 will not go further version 7.0.33 on Debian 9.
First, this repository uses APT Transport over HTTPS. This is basicly getting packages over a TLS connexion.
Let’s install the necesary packages, if you do not have them already:
Then, we add
https://packages.sury.org/php that will be our new source for installing and updating PHP:
If you have already
php7.0 packages installed on your system, you can get patches right away:
Now the installed version of PHP is (at the time of writing)
It contains some patchs from higher version of PHP, added by the community.
This gives you extra time to update your code and support higher version of PHP before upgrading.
You may want to update PHP to a later release, after you’ve made sure your code can support it!
You have 2 options: installing the lastest release (7.3 when this was written), or installing a specific version (7.1 or 7.2). You can also perform both, if you need more than one version installed.
Those operations will not uninstall other version of PHP, and will not change Apache and/or Nginx configuration, so your websites will still use 7.0 by default.
You can now install the current version of PHP (as of today, the 7.3) using:
If the package is already installed, you may need to run instead:
You may want to install any version of PHP using any of the following commands:
You’re free to install any additional extensions that fit your needs.
In order to your server to use the new version of PHP, you have to update its configuration.
On Apache, you need to disable the old PHP handler before using the new.
More advanced configurations will allow you to use different versions of PHP on differents websites if needed.
With Nginx, you just need to edit your fastcgi configuration to make usage of the fpm version you need:
By default, those settings are in nginx.conf, but they may be inside a
sites-availables/ subfolder, or in a included custom configuration file.
fastcgi_pass value according to the PHP version you’d like to use.
Then, simply restart nginx:
If you don’t need it anymore, it can be nice to perform some cleanup operations and remove PHP 7.0 from your server.
Be carefull not to delete package that you still need by reviewing them before confirming!
If the list seems okay, you may confirm the deletion, and now PHP 7.0 is completely gone!