How to Upgrade PHP 8.2 to 8.3 on Ubuntu

Updated on 23 April, 2025
How to Upgrade PHP 8.2 to 8.3 on Ubuntu header image

PHP is a widely used server-side scripting language for building dynamic websites and web applications. PHP offers performance enhancements, language improvements, and modern features with each new release. PHP 8.3 offers advanced capabilities over PHP 8.2 including explicit typing for class constants, readonly classes, deep cloning for readonly properties, and expanded function support.

This article explains how to upgrade PHP 8.2 to PHP 8.3 on Ubuntu 24.04. You will update the PHP repository sources, install PHP 8.3, install PHP-FPM and common PHP extenstions to use PHP with the Apache or Nginx web server.

Prerequisites

Before you begin, you need to:

Add PHP PPA Repository

The default APT package repository sources include limited PHP versions on Ubuntu 24.04. Adding a PHP PPA repository to the APT sources lets you access multiple PHP versions including PHP 8.3 that may not be available in the default APT package sources. Follow the steps below to install Ondřej Surý’s PPA that provides access to updated PHP releases widely used in the PHP community.

  1. Update the APT package index.

    console
    $ sudo apt update
    
  2. Install all required dependency packages.

    console
    $ sudo apt install apt-transport-https ca-certificates software-properties-common -y
    
  3. Add the ondrej/php PPA to your APT repositories.

    console
    $ sudo add-apt-repository -y ppa:ondrej/php
    
  4. Update the APT package index again.

    console
    $ sudo apt update
    

List Installed PHP 8.2 Modules

List all installed PHP 8.2 modules available on your system before upgrading to review all PHP 8.2 components to re-install with PHP 8.3 after the upgrade. Follow the steps below to review the list of actively installed PHP 8.2 modules before upgrading to PHP 8.3.

  1. List all actively installed PHP modules.

    console
    $ php -m
    
  2. List all installed PHP 8.2 related packages and save the list to a packages.txt file.

    console
    $ dpkg -l | grep php8.2 | tee packages.txt
    

    Your output should be similar to the one below.

    php8.2                               server-side, HTML-embedded scripting language (metapackage)
    php8.2-bz2                           bzip2 module for PHP
    php8.2-cli                           command-line interpreter for the PHP scripting language
    php8.2-common                        documentation, examples and common module for PHP
    php8.2-curl                          CURL module for PHP
    php8.2-fpm                           server-side, HTML-embedded scripting language (FPM-CGI binary)
    php8.2-intl                          Internationalisation module for PHP
    php8.2-mbstring                      MBSTRING module for PHP
    php8.2-opcache                       Zend OpCache module for PHP
    php8.2-readline                      readline module for PHP

Install PHP 8.3

PHP 8.3 is available in the default APT package repositories and the PPA source you installed earlier. PHP relies on several system libraries and related software packages, such as the Apache HTTP server and SQLite drivers to run. Follow the steps below to install PHP 8.3 and all core dependencies.

  1. Install PHP 8.3.

    console
    $ sudo apt install -y php8.3
    
  2. Verify the installed PHP 8.3 version.

    console
    $ php8.3 -v
    

    Your output should be similar to the one below.

    PHP 8.3.19 (cli) (built: Mar 13 2025 17:44:40) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.3.19, Copyright (c) Zend Technologies
        with Zend OPcache v8.3.19, Copyright (c), by Zend Technologies
  3. List all installed PHP versions.

    console
    $ ls /etc/php
    

    Verify that both PHP 8.3 and PHP 8.2 are available similar to the following output.

    8.2  8.3

Install PHP 8.3 Extensions

PHP-powered applications often rely on additional libraries and modules to interact with databases and other backend services. Follow the steps below to install common PHP 8.3 extensions.

  1. Update the APT package index.

    console
    $ sudo apt update
    
  2. Run the following command to install the commonly used PHP 8.3 extensions.

    console
    $ sudo apt install -y php8.3-{common,cgi,gd,mysql,pgsql,curl,bz2,mbstring,intl}
    

    The above command installs common PHP 8.3 extensions required by most applications. Add new extensions based on the PHP 8.2 extensions already installed on your system. Within the above command: Within the above command:

    • mbstring: Enables multibyte string support in PHP applications.
    • pgsql: Enables access to PostgreSQL databases.
    • mysql: Connects PHP applications to MySQL databases with improved connections.
    • cgi: Enables support for CGI (Common Gateway Interface) scripts.
    • gd: Enables image manipulation including resizing and cropping with the GD library.
    • curl: Allows PHP to make HTTP requests using cURL.
    • bz2: Adds support for Bzip2 compression in PHP applications.
    • intl: Enables internationalization functions like formatting numbers and dates in PHP applications.

Install PHP 8.3 FPM

PHP-FPM is a process manager that runs PHP as a background service, handling requests from other applications such as web servers, resulting in improved performance. Follow the steps below to install PHP 8.3 FPM.

  1. Update the APT package index.

    console
    $ sudo apt update
    
  2. Install PHP 8.3 FPM.

    console
    $ sudo apt install -y php8.3-fpm
    
  3. Verify the installed PHP FPM version.

    console
    $ php-fpm8.3 -v
    

    Your output should be similar to the one below.

    PHP 8.3.20 (fpm-fcgi) (built: Apr 10 2025 21:33:50)
    Copyright (c) The PHP Group
    Zend Engine v4.3.20, Copyright (c) Zend Technologies
        with Zend OPcache v8.3.20, Copyright (c), by Zend Technologies
  4. Enable the PHP 8.3 FPM service to start at boot,

    console
    $ sudo systemctl enable php8.3-fpm
    

    Output:

    Synchronizing state of php8.3-fpm.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
    Executing: /usr/lib/systemd/systemd-sysv-install enable php8.3-fpm
  5. Start the PHP 8.3 FPM service.

    console
    $ sudo systemctl start php8.3-fpm
    
  6. View the PHP 8.3 service status and verify that its running.

    console
    $ sudo systemctl status php8.3-fpm
    

    Output:

    ● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
       Loaded: loaded (/usr/lib/systemd/system/php8.3-fpm.service; enabled; preset: enabled)
       Active: active (running) since Fri 2025-04-18 21:44:35 UTC; 1min 12s ago
         Docs: man:php-fpm8.3(8)
     Main PID: 35190 (php-fpm8.3)
       Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0.00req/sec"
        Tasks: 3 (limit: 2265)
       Memory: 10.3M (peak: 11.6M)
          CPU: 94ms
       CGroup: /system.slice/php8.3-fpm.service
               ├─35190 "php-fpm: master process (/etc/php/8.3/fpm/php-fpm.conf)"
               ├─35191 "php-fpm: pool www"
               └─35192 "php-fpm: pool www"

Enable PHP 8.3 in Web Server Configurations

The PHP 8.3 FPM configuration is not enabled by default. Follow the steps modify your web server configurations to use PHP 8.3 instead of PHP 8.2.

Apache

Follow the steps below to configure the Apache web server to use PHP 8.3 FPM and disable the old PHP 8.2 configuration.

  1. Enable the PHP 8.3 FPM configuration.

    console
    $ sudo a2enconf php8.3-fpm
    

    Output:

    Enabling conf php8.3-fpm.
  2. Disable the PHP 8.2 FPM configuration.

    console
    $ sudo a2disconf php8.2-fpm
    
  3. Test the Apache configuration for errors.

    console
    $ sudo apachectl configtest
    

    Output:

    Syntax OK
  4. Reload Apache to apply the configuration changes.

    console
    $ sudo systemctl reload apache2
    
  5. View the Apache service status and verify that it's active and running on your server.

    console
    $ sudo systemctl status apache2
    

    Output:

    ● apache2.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
         Active: active (running) since Wed 2025-04-23 15:06:38 UTC; 1min 20s ago
     Invocation: 70b0af54f2de4135ab13bf73ae9a1e47
           Docs: https://httpd.apache.org/docs/2.4/
       Main PID: 8792 (apache2)
          Tasks: 55 (limit: 8761)
         Memory: 6M (peak: 6.2M)
            CPU: 55ms
         CGroup: /system.slice/apache2.service
                 ├─8792 /usr/sbin/apache2 -k start
                 ├─8796 /usr/sbin/apache2 -k start
                 └─8797 /usr/sbin/apache2 -k start

Optional: Uninstall PHP 8.2

Uninstalling PHP 8.2 allows you to use PHP 8.3 as the default PHP version, free up disk space and prevent PHP-FPM port conflicts on the localhost port 9000.

  1. Remove the base PHP 8.2 package using APT.

    console
    $ sudo apt remove -y php8.2
    
  2. Purge all packages related to PHP 8.2, deleting all extensions and configurations.

    console
    $ sudo apt purge php8.2*
    
  3. Remove all unused dependencies.

    console
    $ sudo apt autoremove -y
    
  4. Verify the active PHP version and verify that its PHP 8.3

    console
    $ php -v
    

    Output:

    PHP 8.3.20 (cli) (built: Apr 10 2025 21:33:50) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.3.20, Copyright (c) Zend Technologies
        with Zend OPcache v8.3.20, Copyright (c), by Zend Technologies

Conclusion

You have upgraded from PHP 8.2 to PHP 8.3 on Ubuntu 24.04. You installed essential PHP extensions, enabled PHP-FPM in your web server configurations and uninstalled PHP 8.2 to keep PHP 8.3 as the active version. You can run both PHP versions on the same server and switch configurations to PHP 8.3 or a newer installed version dependng on your project needs. Visit the PHP documentation for more information and advanced configuration options.

Comments

No comments yet.