Well as everyone else says, you should be updating your version of Ubuntu, but, if like me you need to support a website on a platform that can’t be upgraded for whatever reason, for a temporary period, then you may still need to do this.
Curiously, on one server running 16.04.3 LTS, this worked:
sudo apt-get update
sudo apt -y install software-properties-common
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
sudo apt install -y php7.4
But on the second server, which was running the same version, I got:
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package php7.4
E: Couldn't find any package by glob 'php7.4'
E: Couldn't find any package by regex 'php7.4'
PHP7.4 isn’t available for 16.04 on the ondrej repo, so it seems, so why it worked once I have no idea.
The solution I found here: https://stackoverflow.com/questions/67920506/unable-to-install-php-7-4-on-ubuntu-16-04-even-with-ondrej-ppa-repository-in-apa
That is to use the temp non-official external PPA repository instead:
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
This has the required PHP7.4, so installed it fine.
As it is pointed out on the Stack Overflow answer, this should be done being aware of the consequences of using this method.
Other reading, which also explains how to make WordPress use your new PHP version: After upgrading PHP version get Cannot Access Filesystem error on WordPress with nginx
Comments