Skip to content

Instantly share code, notes, and snippets.

@vamuigua
Last active April 18, 2023 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vamuigua/83718617073180e2804100d4a2839754 to your computer and use it in GitHub Desktop.
Save vamuigua/83718617073180e2804100d4a2839754 to your computer and use it in GitHub Desktop.
Install PHP 7.4 on Ubuntu

To install php7.4 on Ubuntu run the following commands in order:

sudo apt-get update
sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt install -y php7.4 php7.4-common php7.4-mysql php7.4-xml php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip

Check Active PHP Version

php -v

You can list all loaded PHP modules with the following command:

php -m

Change Default PHP Version for CLI

You can use the update-alternatives command to set the default PHP version.

Read more details about switching PHP version for CLI and Apache

sudo update-alternatives --config php

Uninstall PHP

sudo apt remove php7.4

Also, uninstall all the modules for that version with the following command:

sudo apt remove php7.4-* 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment