Logo

How to Install PHP 8.0 on Ubuntu 22.04

Aug 08, 2023

To install PHP 8.0 on Ubuntu 22.04, you can follow these steps:

Step 1 : Update the package list:

sudo apt update

Step 2 : Install the software-properties-common package to manage PPA repositories:

sudo apt install software-properties-common

Step 3 : Add the Ondřej Surý's PHP PPA repository:

sudo add-apt-repository ppa:ondrej/php

Step 4 : Update the package list to include the new repository:

sudo apt update

Step 5 : Install PHP 8.0 and necessary packages:

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

Step 6 : Install the extensions you requested:

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

Now, let's briefly explain each of these extensions:

- php8.0-mysql: Allows PHP to communicate with MySQL databases, enabling interaction and manipulation of MySQL databases from your PHP scripts.

- php8.0-curl: Provides functions for making HTTP requests to other servers, allowing your application to interact with external APIs, fetch remote data, and perform various network-related tasks.

- php8.0-xsl: Enables processing and transformation of XML documents using the XSLT (eXtensible Stylesheet Language Transformations) standard.

- php8.0-gd: Enables PHP to work with images, offering functions for creating, manipulating, and rendering images in various formats (e.g., JPEG, PNG, GIF).

- php8.0-common: Includes files shared between the PHP modules, providing common functionalities and utilities that other PHP modules might depend on.

- php8.0-xml: Provides tools for working with XML (eXtensible Markup Language), including parsing and generating XML documents.

- php8.0-zip: Offers functions for creating, reading, and extracting ZIP archives, useful for handling compressed files and archives in your PHP applications.

- php8.0-soap: Enables the Simple Object Access Protocol (SOAP), allowing communication between applications over various protocols.

- php8.0-bcmath: Provides arbitrary precision arithmetic functions, allowing precise mathematical operations, particularly useful for cryptography and financial calculations.

- php8.0-mbstring: Supports multibyte encodings, essential for working with non-ASCII characters and languages that use multibyte character sets (e.g., UTF-8).

- php8.0-gettext: Provides internationalization (i18n) and localization (l10n) support, allowing you to internationalize your PHP applications.

- php8.0-imagick: Offers a PHP wrapper for the ImageMagick library, enabling advanced image manipulation and processing.

Step 7 : Check Installed PHP Version

After installation, you can check the PHP version with the following command:

php -v

That's it! You've successfully installed PHP 8.0 on Ubuntu 22.04.

Recommended