12. Oct 2022 |

php versions

As I use composer packages more and more I need to switch between php versions used in terminal. Some notes here for myself.

  • which php – where php is installed
  • php -v – which php is currently in use in terminal
  • ls -la /usr/bin/php* – which php versions are installed in the system

Install php on Ubuntu

sudo update-alternatives --config php – see options and switch between versions.

For installation I took commands from this instruction.

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Install php7.4 with few common PHP modules (also Digital Ocean post)

sudo apt-get install -y php7.4 php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath

Digital Ocean gives following suggestions for packages:

sudo apt-get install -y php8.1 php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath

For uninstalling just use:

sudo apt remove php7.4 etc or the php -m to list all loaded PHP modules.

sudo apt autoremove

Composer broke down

StackOverflow solution and install composer the old way.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.