Logo

How to Install PHP 7.4 on Ubuntu 24.04

May 02, 2024

To install PHP 7.4 on Ubuntu 24.04, follow the steps below:

Step 1 : First, make sure your package list and installed packages are up to date:

sudo apt update

Step 2 : Add the Ondřej Surý's PPA repository which contains PHP packages:

sudo add-apt-repository ppa:ondrej/php

Step 3 : After adding the repository, update your package list again to include the new repository's packages:

sudo apt update

Step 4 : Install PHP 7.4 and its common modules:

sudo apt install php7.4 php7.4-cli php7.4-fpm

Step 5 : Install the extensions that are commonly used with PHP:

sudo apt install php7.4-{mysql,curl,json,xsl,gd,xml,zip,xsl,soap,bcmath,mbstring,common}

- mysql: MySQL database support

- curl: Client URL library for URL manipulations

- json: JSON support for PHP

- xsl: XSL extension for PHP

- gd: GD library for image processing

- xml: XML support for PHP

- zip: ZIP archive support for PHP

- soap: SOAP extension for PHP

- bcmath: Arbitrary precision mathematics extension for PHP

- mbstring: Multibyte string support for PHP

- common: Common files for PHP

Step 6 : Once the installation is complete, you can verify that PHP 7.4 is installed correctly by checking its version:

php -v

Congratulations! You have successfully installed PHP 7.4 on your Ubuntu 24.04 system.

Recommended