Logo

How to Install PHP 8.3 for Apache on Ubuntu 24.04

Mar 15, 2024

To install PHP 8.3 for Apache on Ubuntu 24.04, follow these steps:

Step 1 : Make sure your package lists are up-to-date by running:

sudo apt update

Step 2 : Find the available PHP versions using apt-cache search:

apt-cache search php8.3

Step 3 : Install PHP 8.3 and libapache2-mod-php8.3

Install PHP 8.3 and the Apache PHP module:

sudo apt install php8.3 libapache2-mod-php8.3

Step 4 : Install commonly used PHP extensions like cgi, mysql, curl, xsl, gd...:

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

  • cgi: Common Gateway Interface, allows PHP scripts to be executed as CGI.
  • mysql: MySQL database connectivity.
  • curl: Allows PHP to communicate with other servers using various protocols.
  • xsl: XSLT processing for transforming XML documents.
  • gd: Graphics library for image processing.
  • common: Common functions and classes.
  • xml: XML support for PHP.
  • zip: ZIP archive management.
  • soap: SOAP protocol support.
  • bcmath: Arbitrary precision mathematics.
  • mbstring: Multibyte string support.
  • gettext: Internationalization support.
  • imagick: PHP extension for ImageMagick.

Step 5 : Check the installed PHP version:

php8.3 -v

Step 6 :Enable the PHP module for Apache:

sudo a2enmod php8.3

Step 7 : Restart Apache for the changes to take effect:

sudo systemctl restart apache2

Step 8 : Create a PHP info file to test PHP processing:

sudo nano /var/www/html/info.php

Add the following content to the file:

<?php
phpinfo();
?>

Step 9 : Open a web browser and navigate to your domain, followed by /info.php (e.g., http://example.com/info.php) to see the PHP info page.

Congratulations! You have successfully installed and configured PHP 8.3 for Apache on Ubuntu 24.04.

Recommended