Forrest logo
back to the apt tool

php:version:install

Install a given PHP version.
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install php${version}
try on your machine

This is a sequence of commands that installs a newer version of PHP onto a Linux system that uses apt for package management (such as Ubuntu or Debian).

  1. sudo apt install software-properties-common: This command installs a package that provides the add-apt-repository command, which is needed to add a new package repository (in this case, ppa:ondrej/php) to the system.

  2. sudo add-apt-repository ppa:ondrej/php: This command adds the ondrej/php repository to the system. This repository provides newer versions of PHP than the default repositories of some Linux distributions.

  3. sudo apt update: This command updates the local package lists with information about packages available in the newly-added repository.

  4. sudo apt install php${version}: This command installs the specified version of PHP (where ${version} is replaced with the desired version number, such as php7.4). This will install the necessary packages for that version of PHP, including any required extensions and dependencies.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the apt tool