How to Install PHP 8.3 on Ubuntu 24.04 (Simple Guide)

How to Install PHP 8.3 on Ubuntu 24.04 (Simple Guide)

Hello readers, in this blog post we will show you how to install PHP 8.3 on Ubuntu 24.04 LTS system step-by-step.

As we know PHP is a server-side scripting language widely used in web development. PHP 8.3 comes with several improvements and new features such as enhanced performance, better error handling, and new language constructs that simplify coding.

Prerequisites

  • Pre-installed Ubuntu 24.04 Instance
  • Local User with sudo rights
  • Internet connectivity

Without any further delay let’s deep dive into PHP 8.3 installation steps on Ubuntu 24.04

1)  Update Your System

It is highly recommended to install all the available updates on your system, open the terminal run following apt commands.

$ sudo apt update
$ sudo apt upgrade -y

2) Install PHP 8.3 Using Default APT Repository

PHP 8.3 and its dependencies are available in the default apt repositories of Ubuntu 24.04. So, for its installation, execute the beneath apt command.

$ sudo apt install php8.3 -y

Once the php is installed, verify its version by running the command.

$ php -v

Alternate Way to Install latest version of PHP 8.3 using third party Repository.

Installing Latest Version of PHP 8.3

At time of writing this post, latest version of PHP was 8.3.11. So in order to install this version, add Ondřej Surý PPA, which is widely trusted in the Ubuntu community.

Run following command:

$ LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php -y

Next, install php 8.3.11 using following apt commands.

$ sudo apt update
$ sudo apt install php8.3 -y

Once installed, execute php -v command to verify php version.

3) Install PHP 8.3 Extensions

To enhance your PHP’s functionality, you should install additional PHP extensions. Here are some commonly used extensions:

$ sudo apt install php8.3-mysql php8.3-xml php8.3-mbstring php8.3-curl php8.3-zip php8.3-gd php8.3-bcmath php8.3-fpm -y

Once above extensions are installed, verify by running the command:

$ php -m

4) Configure PHP 8.3 (Optional)

We can adjust PHP settings by editing the php.ini file. The file location depends on whether you are using PHP for the command line or for a web server:

  • Command Line: /etc/php/8.3/cli/php.ini
  • Web Server (Apache/Nginx): /etc/php/8.3/apache2/php.ini or /etc/php/8.3/fpm/php.ini

To edit the php.ini file, use a text editor like vi/vim,

$ sudo vi /etc/php/8.3/cli/php.ini

Make the changes as per your requirements, save and close the file. Restart the web server if required.

5) Test PHP 8.3 with Web Server

If you are using PHP with a web server like Apache or Nginx, you can test your installation by creating a sample PHP file:

For Apache Web server

Create a PHP file (info.php) in the document root (/var/www/html/) using text editor.

$ sudo vi /var/www/html/info.php
<?php
phpinfo();
?>

Save and close the file.

Now, open the web browser, type following URL:

http://<Your-Ubuntu-24-04-IP-Address>/info.php

For Nginx web server

Create info.php file under the folder /usr/share/nginx/html with following content.

$ sudo vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>

Save and close the file.

This wraps up our guide. We hope you found these instructions helpful and easy to follow. If you have any questions or feedback, feel free to leave a comment below.

Scroll to Top