Home  »  ArticlesGuidesHow ToTechnologyTools   »   A Comprehensive Guide to Installing PHP 8.3 on Ubuntu 24.04 LTS

A Comprehensive Guide to Installing PHP 8.3 on Ubuntu 24.04 LTS

Are you eager to harness the power of PHP 8.3 on your Ubuntu 24.04 LTS system? PHP 8.3 brings forth a vast array of enhancements, performance improvements, and new features, making it a highly anticipated release for developers and enthusiasts alike. In this guide, we’ll walk you through the step-by-step process of installing PHP 8.3 on your Ubuntu 24.04 LTS system, ensuring a seamless setup for your development environment.

Why Upgrade to PHP 8.3?

PHP 8.3 represents a significant evolution in the PHP programming language, introducing numerous enhancements aimed at improving developer productivity, code performance, and security. From new syntax features to performance optimizations, PHP 8.3 empowers developers to build faster, more robust web applications.

Prerequisites

Before we begin the installation process, make sure you have the following prerequisites:

  1. Access to a Terminal: You’ll need to execute commands in a terminal window to install PHP 8.3 and its dependencies.
  2. Sudo Privileges: Ensure that you have sudo privileges or access to the root account to install packages and make system-level changes.
  3. Ubuntu 24.04 LTS: This guide is specifically tailored for Ubuntu 24.04 LTS, so make sure you’re running this version of Ubuntu.

Step 1: Add PHP Repository

To install PHP 8.3 on Ubuntu 24.04 LTS, you’ll need to add the Ondřej Surý PHP repository, which provides up-to-date PHP packages. Follow these commands to add the repository:

$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update

Step 2: Install PHP 8.3

Once the repository is added and updated, you can proceed with the installation of PHP 8.3:

$ sudo apt install php8.3

This command will install PHP 8.3 along with its core modules. Additionally, you may want to install some commonly used PHP extensions. You can search for available extensions using:

$ apt-cache search php8.3-*

Choose the extensions you need and install them using the apt install command for example.

$ sudo apt install php-8.3-fpm php8.3-mysql php8.3-common

Step 3: Verify PHP Installation

After the installation is complete, you can verify that PHP 8.3 is installed correctly by running:

$ php -v

This command will display the PHP version installed on your system, confirming that PHP 8.3 is now available.

Step 4: Configure PHP

Depending on your specific requirements, you may need to configure PHP settings such as php.ini directives, PHP-FPM settings, or Apache/Nginx configurations. These configurations will vary based on your application and environment.

Step 5: Testing PHP

To ensure that PHP is functioning correctly, you can create a simple PHP file and test it in your web browser:

<?php
phpinfo();
?>

Save this file as info.php in your web server’s document root directory (usually /var/www/html/), and then access it in your browser (e.g., http://localhost/info.php). You should see a page displaying PHP configuration information.

Conclusion

Congratulations! You’ve successfully installed PHP 8.3 on your Ubuntu 24.04 LTS system. With PHP 8.3, you can leverage the latest features and enhancements to build powerful web applications with ease. Remember to keep PHP and its extensions up to date to ensure optimal performance and security for your projects.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Articles, Guides, How To, Technology, Tools