Score:1

Install PHP 7.x on Ubuntu 16.04

cn flag

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'
in flag
Ubuntu 18.04 ships with PHP 7.2 in the default repositories. Do you need 7.4 specifically, or will any version in the 7.x line suffice?
BRO_THOM avatar
cn flag
@matigo I'm in the progress of restoring a vm used by a dev which had created all kinds of weird dependencies, so the quickest way to resolve the issue was to remove all php versions and reinstall them. I've however hit this bump. Previously 7.0, 7.2, 7.2, 7.3, 7.4 and 8.0 were installed. But yeah, the goal is to just install any version.
in flag
VMs are generally best treated as disposable objects, so it may be faster to go “scorched earth” and start fresh. That said, if you insist on keeping this VM, which version of PHP do you want to have installed? The default 7.2 or something else?
BRO_THOM avatar
cn flag
@matigo unfortunately that won't be possible, I'm just a simple dev too and we don't have any procedures / virtual images to reinstall them. Not to mention all the other packages that are required. Besides, the VM is "still in use".
BRO_THOM avatar
cn flag
@matigo Lol, I pressed enter so my comment got submitted, anyway. I'd prefer both 7.3 and 7.4. How would I go about installing them? From what I understand using `apt` is basically the only way.
in flag
Looking at the message from apt and your comments, it seems PHP 7.4 (and perhaps five other versions) is already installed on the system. Running an `apt install` will show the above message if the software is already installed and up to date. Are you having trouble switching between the versions?
BRO_THOM avatar
cn flag
@matigo the other version were previously removed using the `apt-get remove php7.x` command and don't seem to be anymore anywhere on the system, so it seems they were uninstalled correctly.
BRO_THOM avatar
cn flag
@matigo just to be sure, I checked to see if I could get another message from `apt-get remove php7.4` but it simply states `0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.`
BRO_THOM avatar
cn flag
@matigo additionally, I've also just noticed that the environment is on Ubuntu 16.04 in stead of the aforementioned 18.04.
in flag
16.04 is EOL and I no longer have any instances of that system to test solutions with. I will *strongly* advise downloading a 20.04 LTS .iso file and building a new VM for the development team to use. Consider this a good learning experience that will add to the value you bring the team
BRO_THOM avatar
cn flag
You're right. Apparently the maintainer for the Ubuntu PHP packages has ceised support for 16.04
Score:2
cn flag

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

Levente avatar
cn flag
Any standard support for 16.04 had been dropped, including OS and application security patches: https://meta.askubuntu.com/q/19582/1157519 This also marks this release as off-topic for this website. See more about this and more about your options in my comments here and below it: https://askubuntu.com/questions/1342277/how-to-change-colour-of-dialogue-window#comment2293435_1342277
BRO_THOM avatar
cn flag
@Levente maybe it's an idea to archive this thread tho due to it's significance in the upcoming days for devs / administrators using legacy software?
Levente avatar
cn flag
That's not up to me to decide... I just wanted to point out that to stay safe, you either need to upgrade to a supported version or explicitly subscribe to extended support.
cl flag
I had to uninstall 7.4 and then reinstall which suddenly started failing and I was going out of my mind trying to figure out why until I saw this answer. Thought I was on 18.04, but this made me check and oops... still 16.04.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.