How to Install PHP 8.1 on Ubuntu 24.10

To install PHP 8.1 on Ubuntu 24.10, follow the steps below

Step 1 : Run the following command to ensure your system is up to date:

Step 2 : Since ppa:ondrej/php does not officially support non-LTS versions of Ubuntu, follow these steps:

- Add the Ondřej Surý PPA for PHP:

- Open the source file:

- Find the word "oracular" and replace it with "noble".

- Save and close the file.

Step 3 : Run the update command to reflect the changes:

Step 4 : Create a preference file to ensure compatibility for specific packages:

Add the following content to the file:

Save and close the file.

Step 5 : Install PHP 8.1 and its core components:

Step 6 : Install the necessary PHP extensions:

- mysql: Connect PHP to MySQL databases.

- curl: Enable communication with REST APIs.

- xsl: Work with XML stylesheets.

- gd: For image manipulation.

- common: Includes base PHP libraries.

- xml: Parse XML data.

- zip: Work with zip archives.

- soap: For SOAP-based web services.

- bcmath: For advanced math operations.

- mbstring: Handle multi-byte strings (e.g., UTF-8).

- gettext: Support for translations.

- imagick: Advanced image processing.

Step 7 : Verify the installed PHP version:

Congratulations! You have successfully installed PHP 8.1 on Ubuntu 24.10 along with its essential extensions.