Logo

How to Install PHP 8.0 on Ubuntu 24.04

May 02, 2024

To install PHP 8.0 on Ubuntu 24.04, follow these steps:

Step 1 : Update

Ensure your system is up to date by running:

sudo apt update

Step 2 : Add the Ondřej Surý PHP PPA repository:

sudo add-apt-repository ppa:ondrej/php

Step 3 : Update your package list to include the newly added repository:

sudo apt update

Step 4 : Install PHP 8.0 core packages including CLI and FPM:

sudo apt install php8.0 php8.0-cli php8.0-fpm

Step 5 : Install commonly used PHP extensions such as MySQL, cURL, XSL, GD, XML, Zip, SOAP, BCMath, Mbstring, and Imagick:

sudo apt install php8.0-{mysql,curl,xsl,gd,common,xml,zip,xsl,soap,bcmath,mbstring}

Explanation of Extensions:

- php8.0-mysql: MySQL database support

- php8.0-curl: Client URL library for URL handling

- php8.0-xsl: XSL module for PHP

- php8.0-gd: GD library for image processing

- php8.0-common: Common files for PHP

- php8.0-xml: XML module for PHP

- php8.0-zip: ZIP archive support

- php8.0-soap: SOAP module for PHP

- php8.0-bcmath: BCMath arbitrary precision mathematics module for PHP

- php8.0-mbstring: Multibyte string module for PHP

Step 6 : Verify that PHP 8.0 is installed by checking the version:

php -v

Congratulations! You have successfully installed PHP 8.0 on Ubuntu 24.04.

Recommended