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.

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.
- Prerequisites and Supported Releases
- Step 1: Auditing Existing PHP 8.2 Extensions
- Step 2: Adding the Official Ondrej Sury PHP PPA
Interactive Builder for this Guide
Build your custom nginx syntax (How to Upgrade PHP 8.2 to 8.3 in Ubuntu)
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";
}
}server_nameBinds this virtual host to app.example.comreturn 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPSproxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application serverX-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjackingPHP 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.
Complete step-by-step developer and system administrator tutorial on upgrading from PHP 8.2 to PHP 8.3 on Ubuntu 24.04 LTS and 22.04 LTS. Covers adding the official Ondrej Sury PPA, auditing and migrating installed extensions, updating Apache mod_php and Nginx PHP-FPM socket pools, switching CLI versions with update-alternatives, and safely removing deprecated PHP 8.2 packages.
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
sudoadministrative 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:
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.
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.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Install LEMP Stack on Ubuntu 24.04 — Deploy complete high-performance Nginx, MySQL, and PHP 8.3 stacks.
- How to Install and Configure Caddy on Ubuntu 24.04 — Configure modern automated HTTPS web servers with PHP-FPM.
- Initial Server Setup on Ubuntu 24.04 LTS — Foundational Linux server security hardening guide.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
/etc/php/8.3/fpm/php.ini. For the command-line interface, it resides at /etc/php/8.3/cli/php.ini.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
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.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!