Website Vidya
DevelopmentStep-by-Step Guide

How to Upgrade PHP 8.2 to 8.3 in Ubuntu

Learn how to upgrade php 8.2 to 8.3 in ubuntu 24.04 and 22.04 with Ondrej PPA, extension migration, Nginx/Apache integration, and cleanup.

RR
Rajesh RayLead Systems Educator
Published:
5 min read
PDF Cheat Sheet
How to Upgrade PHP 8.2 to 8.3 in Ubuntu
AI Executive SummaryCORE CIS AI

5 min read

Learn how to upgrade php 8.2 to 8.3 in ubuntu 24.04 and 22.04 with Ondrej PPA, extension migration, Nginx/Apache integration, and cleanup.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Auditing Existing PHP 8.2 Extensions
  • Step 2: Adding the Official Ondrej Sury PHP PPA
Grounded in full engineering runbookCORE CIS Ai Engine

Interactive Builder for this Guide

Build your custom nginx syntax (How to Upgrade PHP 8.2 to 8.3 in Ubuntu)

Generated Config Output
server {
    listen 80;
    listen [::]:80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name app.example.com;

    ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    gzip on;
    gzip_types text/plain text/css application/json application/javascript application/xml;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
Production Nginx reverse proxy -> 127.0.0.1:3000 for app.example.com.
Flag-by-Flag Breakdown
server_nameBinds this virtual host to app.example.com
return 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPS
proxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application server
X-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjacking

PHP powers over 75% of web servers across the internet, serving as the foundational execution runtime for WordPress, Laravel, Drupal, Symfony, and custom web applications.

PHP 8.3 introduces substantial performance improvements, typed class constants, the json_validate() function, dynamic class constant fetches, and critical security patches over PHP 8.2.

Upgrading an active web server from PHP 8.2 to PHP 8.3 requires a structured methodology to ensure that web servers (Nginx or Apache) update their fastCGI backend sockets and all required extensions (such as MySQL, cURL, GD, and XML) transfer seamlessly.

In this guide, we walk through how to upgrade php 8.2 to 8.3 in ubuntu safely with zero data loss, minimal downtime, and clean package maintenance.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A server running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS with PHP 8.2 installed.
  • A non-root user account with sudo administrative privileges.
  • A working web server (Nginx or Apache) serving PHP applications.
  • A verified backup of your website configuration files and databases.

Step 1: Auditing Existing PHP 8.2 Extensions

Before installing PHP 8.3, record the complete list of active PHP 8.2 extensions to ensure your application stack does not experience missing dependency errors.

Run the following command to export installed PHP 8.2 module names to a text file:

Advertisement

Review your current active PHP CLI version:

# Check active PHP version:
php -v
# Output confirms: PHP 8.2.x ...

# Export list of installed PHP 8.2 extensions:
dpkg -l | grep php8.2 | awk '{print $2}' > ~/php8.2-installed-packages.txt

# View the installed modules:
cat ~/php8.2-installed-packages.txt

Step 2: Adding the Official Ondrej Sury PHP PPA

Ondrej Sury is the official Debian and Ubuntu PHP packaging maintainer.

His official Personal Package Archive (PPA) provides verified, continuously updated builds for all active PHP releases on Ubuntu.

Install software-properties-common and register the repository:

# Install software properties utility:
sudo apt update
sudo apt install -y software-properties-common

# Add Ondrej Sury PHP repository:
sudo add-apt-repository -y ppa:ondrej/php

# Refresh package cache:
sudo apt update

Step 3: Installing PHP 8.3 and Matching Extensions

Install the core PHP 8.3 binaries along with the common extensions identified in your audit from Step 1.

Advertisement

Install the primary web extensions required by WordPress, Laravel, and modern frameworks:

If your server runs Nginx, install php8.3-fpm; if running Apache, install libapache2-mod-php8.3:

# Install PHP 8.3 CLI, FPM, and standard web extensions:
sudo apt install -y php8.3 php8.3-cli php8.3-common php8.3-fpm \
  php8.3-mysql php8.3-curl php8.3-gd php8.3-mbstring php8.3-xml \
  php8.3-zip php8.3-bcmath php8.3-intl php8.3-readline php8.3-opcache

# Verify PHP 8.3 CLI installation:
php8.3 -v
# Output confirms: PHP 8.3.x (cli) ...

Step 4: Updating Web Server Configuration (Nginx & Apache)

Installing PHP 8.3 does not automatically instruct your web server to route HTTP requests to the new PHP engine.

Depending on whether you use Nginx or Apache, update the web server configuration to point to PHP 8.3:

Option A: Updating Nginx to Use php8.3-fpm Socket

Nginx communicates with PHP over a UNIX domain socket managed by PHP-FPM.

Open your Nginx site configuration in /etc/nginx/sites-available/ and update the fastcgi_pass directive:

Test syntax and reload Nginx:

# In your Nginx server block configuration:
# Replace fastcgi_pass unix:/run/php/php8.2-fpm.sock;
# With:
fastcgi_pass unix:/run/php/php8.3-fpm.sock;

# Test Nginx syntax configuration:
sudo nginx -t

# Reload Nginx to activate PHP 8.3:
sudo systemctl reload nginx

Option B: Updating Apache to Use PHP 8.3 Module

For Apache web servers running mod_php, disable the old PHP 8.2 module and enable the new PHP 8.3 module:

Restart Apache to apply the changes:

# Disable PHP 8.2 module in Apache:
sudo a2dismod php8.2

# Enable PHP 8.3 module in Apache:
sudo a2enmod php8.3

# Restart Apache web server:
sudo systemctl restart apache2

Step 5: Setting the Default PHP Version for CLI (update-alternatives)

If multiple versions of PHP are installed simultaneously, update Ubuntu's symbolic links so the php command defaults to PHP 8.3:

Execute update-alternatives for the PHP binary and PHP-FPM daemon:

# Set default CLI php binary:
sudo update-alternatives --set php /usr/bin/php8.3

# Set default phar and phpize tools:
sudo update-alternatives --set phar /usr/bin/phar8.3
sudo update-alternatives --set phpize /usr/bin/phpize8.3

# Confirm default system version:
php -v
# Output confirms: PHP 8.3.x

Step 6: Safely Removing Obsolete PHP 8.2 Packages

After thoroughly testing your website and confirming that all application features function properly under PHP 8.3, remove the old PHP 8.2 packages to free disk space and reduce security audit overhead:

Purge PHP 8.2 packages using apt purge:

# Remove all PHP 8.2 packages:
sudo apt purge -y php8.2*

# Clean up unneeded orphan dependencies:
sudo apt autoremove -y

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

502 Bad Gateway displayed in browser after Nginx reload

Cause: The php8.3-fpm service is not running or the socket path in Nginx is misconfigured.

Resolution: Start the service with sudo systemctl start php8.3-fpm and verify /run/php/php8.3-fpm.sock exists.

sudo systemctl status php8.3-fpm

Fatal error: Uncaught Error: Call to undefined function mysqli_connect()

Cause: The php8.3-mysql database driver extension was not installed.

Resolution: Install the extension with sudo apt install -y php8.3-mysql and restart your web server.

sudo apt install -y php8.3-mysql && sudo systemctl reload php8.3-fpm

CLI reports PHP 8.2 while web server reports PHP 8.3

Cause: The CLI default binary was not updated using update-alternatives.

Resolution: Execute sudo update-alternatives --set php /usr/bin/php8.3.

sudo update-alternatives --set php /usr/bin/php8.3

Security Best Practices and Hardening

Always verify application compatibility and staging tests before upgrading PHP in production to catch deprecated functions.

Review custom php.ini directives (such as upload_max_filesize, memory_limit, and post_max_size) in /etc/php/8.3/fpm/php.ini to match your previous PHP 8.2 settings.

Ensure expose_php = Off is set in /etc/php/8.3/fpm/php.ini to prevent broadcasting your exact runtime version in HTTP response headers.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
Yes. Ubuntu supports parallel multi-version PHP installations. You can run PHP 8.2 for legacy applications and PHP 8.3 for newer websites simultaneously by routing different Nginx server blocks to distinct PHP-FPM UNIX domain sockets.
No. Upgrading PHP only updates the server-side code execution runtime. Your database records, MySQL schemas, media uploads, and theme files remain completely untouched.
For PHP-FPM, the configuration file is at /etc/php/8.3/fpm/php.ini. For the command-line interface, it resides at /etc/php/8.3/cli/php.ini.
PHP 8.3 has minimal breaking changes compared to PHP 8.0, but removes several deprecated functions and tightens typing on class constants and datetime exceptions. Most modern PHP 8.2 codebases run seamlessly on PHP 8.3 without modifications.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Uncategorized•

How to Redirect HTTP to HTTPS in Nginx

If you’re running a website today and it’s still accessible over plain HTTP, you’re already behind. Modern browsers flag non-HTTPS sites as “Not Secure,” search engines favor encrypted websites, and users are far more cautious about where t...

RR
Rajesh Rai
Read More
Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout