How do I get each server to run same ver. of PHP?

I have two Linode servers… Saturn and Mars.

Each run Ubuntu 20.04.3 LTS (GNU/Linux 5.14.17-x86_64-linode150 x86_64)

Saturn was spun up brand new with 20.04 LTS about 7 months ago.

Mars is a five year old server that started out as Ubuntu 16.x and I did an "sudo do-release-upgrade" or something like that to bring it to 20.04 about six months ago. Worked fine.

Why does each server have a different version of PHP… Mars has the older PHP version:

Mars (older server):

xxx@mars:/var/www/html$ php --version
PHP 7.4.26 (cli) (built: Nov 22 2021 09:48:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies

Saturn (new server):

xxx@saturn:/var/www/html$ php --version
PHP 7.4.3 (cli) (built: Oct 25 2021 18:20:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

How do I get Mars with PHP 7.4.26 to install and run PHP 7.4.3? like the newer Saturn?

What does this show for Mars?

xxx@mars:/var/www/html$ apt policy php7.4
php7.4:
Installed: 7.4.26-1+ubuntu20.04.1+deb.sury.org+2
Candidate: 7.4.26-1+ubuntu20.04.1+deb.sury.org+2
Version table:
*** 7.4.26-1+ubuntu20.04.1+deb.sury.org+2 500
500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages
500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main i386 Packages
100 /var/lib/dpkg/status
7.4.3-4ubuntu2.8 500
500 http://mirrors.linode.com/ubuntu focal-updates/main amd64 Packages
500 http://mirrors.linode.com/ubuntu focal-updates/main i386 Packages
7.4.3-4ubuntu2.7 500
500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
7.4.3-4ubuntu1 500
500 http://mirrors.linode.com/ubuntu focal/main amd64 Packages
500 http://mirrors.linode.com/ubuntu focal/main i386 Packages

7 Replies

Do both servers pull PHP from the same repository? It looks like one is a ppa which might be your issue.

Mars is using a PPA for PHP, which is something I STRONGLY recommend against doing. Again with the word strongly, but I STRONGLY advise using the version of php that's in Ubuntu's repositories, even if it is slightly older. Packages in "main" - like PHP - receive direct security support from Canonical/Ubuntu. Packages in a PPA do not. You're at the mercy of whoever runs that PPA to provide security updates in a timely manner. Secure is better than newer in virtually all cases.

I see where you get PPA. Saturn does not have that:

xxxx@saturn:/var/www/html$ apt policy php7.4
php7.4:
Installed: 7.4.3-4ubuntu2.7
Candidate: 7.4.3-4ubuntu2.8
Version table:
7.4.3-4ubuntu2.8 500
500 http://mirrors.linode.com/ubuntu focal-updates/main amd64 Packages
*** 7.4.3-4ubuntu2.7 500
500 http://mirrors.linode.com/ubuntu focal-security/main amd64 Packages
100 /var/lib/dpkg/status
7.4.3-4ubuntu1 500
500 http://mirrors.linode.com/ubuntu focal/main amd64 Packages

So, how do I NOT get PPA. Here are the "apt get update" of each. I don't see a PPA repo. :

Saturn

xxx@yyy:/var/www/html$ sudo apt update
[sudo] password for xxx:
Hit:1 http://mirrors.linode.com/ubuntu focal InRelease
Get:2 http://mirrors.linode.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://mirrors.linode.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://mirrors.linode.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://mirrors.linode.com/ubuntu focal-updates/main amd64 Packages [1,397 kB]
Get:6 http://mirrors.linode.com/ubuntu focal-updates/main Translation-en [283 kB]
Get:7 http://mirrors.linode.com/ubuntu focal-updates/main amd64 c-n-f Metadata [14.6 kB]
Get:8 http://mirrors.linode.com/ubuntu focal-updates/restricted amd64 Packages [613 kB]
Get:9 http://mirrors.linode.com/ubuntu focal-updates/restricted Translation-en [87.8 kB]
Get:10 http://mirrors.linode.com/ubuntu focal-updates/universe amd64 Packages [882 kB]
Fetched 3,613 kB in 1s (4,038 kB/s)

Mars

aaa@bbb:/var/www/html$ sudo apt update
[sudo] password for xxxxx:
Hit:1 http://mirrors.linode.com/ubuntu focal InRelease
Get:2 http://mirrors.linode.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://mirrors.linode.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://mirrors.linode.com/ubuntu focal-updates/main i386 Packages [573 kB]
Get:5 http://mirrors.linode.com/ubuntu focal-updates/main amd64 Packages [1,397 kB]
Get:6 http://mirrors.linode.com/ubuntu focal-updates/main Translation-en [283 kB]
Get:7 http://mirrors.linode.com/ubuntu focal-updates/main amd64 c-n-f Metadata [14.6 kB]
Get:8 http://mirrors.linode.com/ubuntu focal-updates/restricted amd64 Packages [613 kB]
Get:9 http://mirrors.linode.com/ubuntu focal-updates/restricted Translation-en [87.8 kB]
Get:10 http://mirrors.linode.com/ubuntu focal-updates/universe amd64 Packages [882 kB]
Get:11 http://mirrors.linode.com/ubuntu focal-updates/universe i386 Packages [653 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:13 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Hit:14 http://ppa.launchpad.net/phpmyadmin/ppa/ubuntu focal InRelease
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [667 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [112 kB]
Fetched 5,618 kB in 2s (3,220 kB/s)
Reading package lists… Done

I see where PPA is now.

PPA-ondrej-php

Here is the "apt policy" for each. How do I get rid of PPA-ondrej-php… and then what do I do to get PHP back>?

Saturn

xxxx@saturn:/var/www/html$ apt policy
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://mirrors.linode.com/ubuntu focal-security/multiverse amd64 Packages
release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=multiverse,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-security/universe amd64 Packages
release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=universe,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-security/restricted amd64 Packages
release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=restricted,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-security/main amd64 Packages
release v=20.04,o=Ubuntu,a=focal-security,n=focal,l=Ubuntu,c=main,b=amd64
origin mirrors.linode.com
100 http://mirrors.linode.com/ubuntu focal-backports/universe amd64 Packages
release v=20.04,o=Ubuntu,a=focal-backports,n=focal,l=Ubuntu,c=universe,b=amd64
origin mirrors.linode.com
100 http://mirrors.linode.com/ubuntu focal-backports/main amd64 Packages
release v=20.04,o=Ubuntu,a=focal-backports,n=focal,l=Ubuntu,c=main,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-updates/multiverse amd64 Packages
release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=multiverse,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-updates/universe amd64 Packages
release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=universe,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-updates/restricted amd64 Packages
release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=restricted,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal-updates/main amd64 Packages
release v=20.04,o=Ubuntu,a=focal-updates,n=focal,l=Ubuntu,c=main,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal/multiverse amd64 Packages
release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=multiverse,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal/universe amd64 Packages
release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal/restricted amd64 Packages
release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=restricted,b=amd64
origin mirrors.linode.com
500 http://mirrors.linode.com/ubuntu focal/main amd64 Packages
release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=main,b=amd64
origin mirrors.linode.com

Mars

xxxx@mars:/var/www/html$ apt policy
Package files:
100 /var/lib/dpkg/status
release a=now
500 http://ppa.launchpad.net/phpmyadmin/ppa/ubuntu focal/main i386 Packages
release v=20.04,o=LP-PPA-phpmyadmin,a=focal,n=focal,l=PPA for phpMyAdmin,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/phpmyadmin/ppa/ubuntu focal/main amd64 Packages
release v=20.04,o=LP-PPA-phpmyadmin,a=focal,n=focal,l=PPA for phpMyAdmin,c=main,b=amd64
origin ppa.launchpad.net
500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main i386 Packages
release v=20.04,o=LP-PPA-ondrej-php,a=focal,n=focal,l= The main PPA for supported PHP versions with many PECL extensions ,c=main,b=i386
origin ppa.launchpad.net
500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages
release v=20.04,o=LP-PPA-ondrej-php,a=focal,n=focal,l= The main PPA for supported PHP versions with many PECL extensions ,c=main,b=amd64
origin ppa.launchpad.net

Remove the PPA repositories and add the Ubuntu repositories if they’re missing. Then install PHP packages from them.

Your repository list should be here:

/etc/apt/sources.list

FYI: It might break things, so I’d backup first.

Do you have a step-by-step methodology for dumping the PPA repos and then installing PHP 7.4?

What about using "ppa-purge" on Ubuntu 20.x? I understand that will kill the ondrej repo and the programs with it… but what is the process to reinstall php 7.4? Just an "apt get full-update"?

Thanks.

I did some research and decided to run "sudo ppa-purge".

It worked great… got all the PHP files up to PHP 7.4.3.

Done and done.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct