Install PHP 7.x on Ubuntu 16.04
I know this question has been asked a lot, but I've always been led to the same answer which is not resolving my issue.
The solution that's provided is usually along these lines:
~$ sudo apt-get install software-properties-common python-software-properties;
~$ sudo add-apt-repository -y ppa:ondrej/php;
~$ sudo apt-get update;
And it's done! But not in my case unfortunately.
So after executing the previously mentioned steps, I'm trying to install "any" PHP 7.x version via apt
but it appears the packages for any version of PHP can't be found.
~$ sudo apt install php7.4;
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree
Reading state information... Done
Note, selecting 'php7.4-gd' for regex 'php7.4'
Note, selecting 'php7.4-cli' for regex 'php7.4'
Note, selecting 'php7.4-dom' for regex 'php7.4'
Note, selecting 'php7.4-ffi' for regex 'php7.4'
Note, selecting 'php7.4-ftp' for regex 'php7.4'
Note, selecting 'php7.4-xmlreader' for regex 'php7.4'
Note, selecting 'php7.4-mysqli' for regex 'php7.4'
Note, selecting 'php7.4-sysvmsg' for regex 'php7.4'
Note, selecting 'php7.4-json' for regex 'php7.4'
Note, selecting 'php7.4-phar' for regex 'php7.4'
Note, selecting 'php7.4-tokenizer' for regex 'php7.4'
Note, selecting 'php7.4-curl' for regex 'php7.4'
Note, selecting 'php7.4-shmop' for regex 'php7.4'
Note, selecting 'php7.4-pdo-mysql' for regex 'php7.4'
Note, selecting 'php7.4-sysvsem' for regex 'php7.4'
Note, selecting 'php7.4-sysvshm' for regex 'php7.4'
Note, selecting 'php7.4-pdo' for regex 'php7.4'
Note, selecting 'php7.4-sockets' for regex 'php7.4'
Note, selecting 'php7.4-ctype' for regex 'php7.4'
Note, selecting 'php7.4-calendar' for regex 'php7.4'
Note, selecting 'php7.4-intl' for regex 'php7.4'
Note, selecting 'php7.4-fileinfo' for regex 'php7.4'
Note, selecting 'php7.4-opcache' for regex 'php7.4'
Note, selecting 'php7.4-soap' for regex 'php7.4'
Note, selecting 'php7.4-xml' for regex 'php7.4'
Note, selecting 'php7.4-xsl' for regex 'php7.4'
Note, selecting 'php7.4-zip' for regex 'php7.4'
Note, selecting 'php7.4-simplexml' for regex 'php7.4'
Note, selecting 'php7.4-mysql' for regex 'php7.4'
Note, selecting 'php7.4-mbstring' for regex 'php7.4'
Note, selecting 'php7.4-readline' for regex 'php7.4'
Note, selecting 'php7.4-exif' for regex 'php7.4'
Note, selecting 'php7.4-mysqlnd' for regex 'php7.4'
Note, selecting 'php7.4-common' for regex 'php7.4'
Note, selecting 'php7.4-bcmath' for regex 'php7.4'
Note, selecting 'php7.4-posix' for regex 'php7.4'
Note, selecting 'php7.4-iconv' for regex 'php7.4'
Note, selecting 'libapache2-mod-php7.4' for regex 'php7.4'
Note, selecting 'php7.4-gettext' for regex 'php7.4'
Note, selecting 'php7.4-xmlwriter' for regex 'php7.4'
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
What's also interesting, is that when I use apt search
is that there really doesn't seem to be a package for any php
version
~$ sudo apt search php7.4
Sorting... Done
Full Text Search... Done
libapache2-mod-php7.4/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-bcmath/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-cli/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-common/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-curl/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-gd/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-intl/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
php7.4-json/now 7.4.13-1+ubuntu16.04.1+deb.sury.org+1 amd64 [residual-config]
(none)
... etc
What am I missing?
Edit: after executing apt-get purge php7.4
the message for (at least PHP 7.4) has changed to the following:
~$ sudo apt-get install -y php7.4
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'
For anyone interested;
PHP support for Ubuntu xenial 16.04 has dropped since 2021-06-10. I've found this out the hard way when I also tried installing PHP modules / versions on other VM's that use 16.04 and apparently "couldn't find packages" when other machine had previously installed them with ease.
There's a post on stackoverflow describing this: https://stackoverflow.com/questions/67920506/unable-to-install-php-7-4-on-ubantu-16-04-even-with-ondrej-ppa-repository-in-apa