Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Ubuntu 22.04 LTS and PHP 8.0

Hello,

I'm using Ubuntu 22.04 LTS.

I'm used to use update-alternatives to switch between PHP.

I'm trying to install PHP 8.0, but I have dependencies problems.

I also thought about using sail, but this application has been developped with PHP 8.0 and I can't install sail without having PHP 8.0.

What do you suggest me to install this version ?

(I don't want to use a virtual machine, unless there isn't any other solution)

Thanks for your help.

V

0 likes
7 replies
vincent15000's avatar

ChatGPT suggests me to use ppa:ondrej/php repository, but I already tried this and I get the error.

Lecture des listes de paquets... Fait Construction de l'arbre des dépendances... Fait Lecture des informations d'état... Fait
Vous pouvez lancer « apt --fix-broken install » pour corriger ces problèmes. Les paquets suivants contiennent des dépendances non satisfaites : gstreamer1.0-packagekit : Dépend: packagekit (= 1.2.5-2ubuntu3) mais 1.2.5-2ubuntu2 devra être installé packagekit-tools : Dépend: packagekit (= 1.2.5-2ubuntu3) mais 1.2.5-2ubuntu2 devra être installé php8.0 : Dépend: php8.0-common mais ne sera pas installé php8.0-cli : Dépend: php8.0-common (= 1:8.0.30-12+ubuntu22.04.1+deb.sury.org+1) mais ne sera pas installé Dépend: php8.0-opcache mais ne sera pas installé Dépend: php8.0-readline mais ne sera pas installé php8.0-curl : Dépend: php8.0-common (= 1:8.0.30-12+ubuntu22.04.1+deb.sury.org+1) mais ne sera pas installé php8.0-fpm : Dépend: php8.0-common (= 1:8.0.30-12+ubuntu22.04.1+deb.sury.org+1) mais ne sera pas installé Dépend: php8.0-opcache mais ne sera pas installé php8.0-mbstring : Dépend: php8.0-common (= 1:8.0.30-12+ubuntu22.04.1+deb.sury.org+1) mais ne sera pas installé php8.0-mysql : Dépend: php8.0-common (= 1:8.0.30-12+ubuntu22.04.1+deb.sury.org+1) mais ne sera pas installé php8.0-xml : Dépend: php8.0-common (= 1:8.0.30-12+ubuntu22.04.1+deb.sury.org+1) mais ne sera pas installé E: Dépendances non satisfaites. Essayez « apt --fix-broken install » sans paquet (ou indiquez une solution).

RemiM's avatar

@vincent15000 Have you tried:

sudo apt --fix-broken install

as suggested in the error message?

1 like
vincent15000's avatar

@RemiM No I don't have tried this ... I already did this in the past on previous Ubuntu versions and it wasn't a good idea because then I had big malfunctions on my computer. So I prefer trying something else if possible.

jlrdw's avatar

I found it really is easy to change what little code there is to php 8.3. The wiki shows changes between versions.

Merklin's avatar

Just fired up a VM yesterday. The way to install an additional PHP version is:

sudo add-apt-repository ppa:ondrej/php
sudo apt update

apt-get -y install php8.0 php8.0-common php8.0-gd php8.0-mysql php8.0-imap php8.0-cli php8.0-cgi php8.0-curl php8.0-intl php8.0-pspell php8.0-sqlite3 php8.0-tidy php8.0-xmlrpc php8.0-xsl php8.0-zip php8.0-mbstring php8.0-soap php8.0-opcache php8.0-fpm

and then use the sudo update-alternatives --config php to switch versions.

Same code can be used for 8.1, 8.2, 8.3 etc. Just replace the 8.0 part.

1 like
vincent15000's avatar

@Merklin That's exactly what I have done, but when I install the php8.0-xxx packages, I get the error mentioned in my post.

With which Ubuntu version have you tried ?

Please or to participate in this conversation.