2

While I know that php 8 is the default PHP choice on Ubuntu 22.04, I still use php 7 for my project. When installing packages related to PHP, the dependancies always pick php-common, php-*, etc.. and end up installing php 8 on the server.

Currently I have trouble installing Composer via apt install composer

So how do I tell the system that php-* is always mapped to php7.4-* and force libraries to always pick this given php version?

2 Answers2

2

PHP7 is no longer available in the core repository of Ubuntu 22.04, but you can install it using the PPA documented at https://launchpad.net/~ondrej/+archive/ubuntu/php/

1

To add support for older php version to be installed:

add-apt-repository ppa:ondrej/php && apt update -y

AFter you install the php7.4 packages you need, the following command will prompt you to select the default php version:

sudo update-alternatives --config php

Alex
  • 11