How to Install PHP 8.1 for Apache on Ubuntu 23.04

To install PHP 8.1 for Apache on Ubuntu 23.04, follow the steps below:

Step 1 : Update

Ensure your system is up to date by running:

Step 2 : Find PHP Version

Discover available PHP versions using the command:

Step 3 : Install PHP 8.1 and Apache Module

Install PHP 8.1 and the Apache module with:

Step 4 : Install Common PHP Extensions

Install commonly used PHP extensions with the command:

- cgi: Common Gateway Interface for web servers.

- mysql: MySQL database connectivity.

- curl: Client URL library for data transfer.

- xsl: XSL Transformation for XML.

- gd: Graphics Draw library for image creation.

- common: Common functions and classes.

- xml: Extensible Markup Language support.

- zip: Zip archive support.

- soap: Simple Object Access Protocol for web services.

- bcmath: Arbitrary precision mathematics.

- mbstring: Multibyte string support.

- gettext: Internationalization functions.

- imagick: ImageMagick PHP extension for image processing.

Step 5 : Verify PHP Version

Check the installed PHP version:

Step 6 : Configure Apache to Use PHP

Enable the PHP module for Apache:

Step 7 : Restart Apache

Restart Apache to apply the changes:

Step 8 : Test PHP

Create a PHP info file:

Step 9 : Domain Check

Visit your domain followed by /info.php to see the PHP info:

Congratulations! You have successfully installed PHP 8.1 for Apache on Ubuntu 23.04!