PHP code programming

Safe PHP Version Upgrade on VPS Without Breaking Sites

June 2026 · 7 min read

PHP 7.4 reached end-of-life (EOL) back in November 2022. If you're still running an old PHP version, it means your website is not receiving security patches—there are known vulnerabilities with no fixes. This article outlines how to plan and execute a PHP upgrade step-by-step.


Why You Should Upgrade PHP

Check Your Current PHP Version

php -v
php-fpm8.1 -v   # or your current version

Add Ondřej Surý PPA (Ubuntu)

Ubuntu ships with older PHP versions in the default repository. Add Ondřej Surý's PPA, maintained by the official Debian PHP maintainer:

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

Install PHP 8.3 and Extensions

apt install php8.3 php8.3-fpm php8.3-cli \
  php8.3-mysql php8.3-curl php8.3-gd \
  php8.3-mbstring php8.3-xml php8.3-zip \
  php8.3-intl php8.3-bcmath php8.3-imagick

Test Before Switching

Before switching production, test that your application works with the new PHP version:

# Test via CLI first
php8.3 -f /var/www/html/index.php

# Check for syntax errors
php8.3 -l /var/www/html/wp-config.php

Update Nginx to Use the New PHP-FPM

# Edit your nginx config
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
# Previously might have been php8.1-fpm.sock

nginx -t && systemctl reload nginx

Update Apache to Use the New PHP-FPM

a2disconf php8.1-fpm
a2enconf php8.3-fpm
systemctl restart apache2

Copy Over Your Previous php.ini Settings

diff /etc/php/8.1/fpm/php.ini /etc/php/8.3/fpm/php.ini

Review the differences and copy over any settings you previously customized, such as upload_max_filesize, memory_limit, and max_execution_time

Rollback Plan if Problems Occur

# Switch back to PHP 8.1 in Nginx
fastcgi_pass unix:/run/php/php8.1-fpm.sock;

nginx -t && systemctl reload nginx

Do not delete the old PHP version immediately. Keep it for a while until you're confident everything is working normally.

WordPress: Before upgrading PHP, check compatibility of all active plugins. Use a tool like PHP Compatibility Checker to verify.

Verify Domain Health and SSL After Upgrade

After upgrading PHP, verify that your website is running smoothly in all aspects—SSL, response headers, and DNS. Tools like dnsxray.com help check your website health quickly in a single page.

If you're looking for a VPS with a managed PHP environment or hosting that maintains the stack for you, asiagb.com offers both VPS and shared hosting options with modern PHP versions.


Summary

PHP upgrade isn't difficult if you follow the steps. Install the new version alongside the old, test thoroughly, then switch. No need to rush deleting the old version. The security and performance benefits are well worth the time invested.

Verify PHP Upgrade Was Successful

# Check PHP CLI version
php -v

# Check running PHP-FPM
systemctl status php8.3-fpm

# Create a temporary test file
echo "<?php echo phpversion();" > /var/www/html/phpver.php
curl -s https://example.com/phpver.php
rm /var/www/html/phpver.php   # Delete immediately
Verify extensions: Run php8.3 -m to list loaded extensions and compare with your old PHP version. If any are missing, install them with apt install php8.3-name

Common Issues & Troubleshooting

Error: "PHP Fatal error: Call to undefined function imagecreatetruecolor()"

The GD extension is not installed for the new PHP version:

apt install php8.3-gd
systemctl restart php8.3-fpm

Error: WordPress shows blank page after PHP upgrade

PHP 8.x is stricter about deprecated syntax. Check the error log:

# View error logs
tail -f /var/log/nginx/error.log
tail -f /var/log/php8.3-fpm.log

# Enable debug temporarily in wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

Error: "No input file specified" or 502 after changing Nginx config

The socket path does not match the new PHP-FPM socket:

# List available sockets
ls -la /run/php/
# You may see: php8.3-fpm.sock

# Update nginx config
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
nginx -t && systemctl reload nginx

Cannot upload large files after upgrade

The new PHP version uses default values. Reconfigure php.ini:

# Edit /etc/php/8.3/fpm/php.ini
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
memory_limit = 256M

systemctl restart php8.3-fpm

Missing bcmath / intl / mbstring extensions

apt install php8.3-bcmath php8.3-intl php8.3-mbstring php8.3-xml php8.3-zip
systemctl restart php8.3-fpm

Frequently Asked Questions

Can I run multiple PHP versions on the same server?

Yes. Each PHP-FPM version runs as a separate service. Your Nginx config can point each virtual host to a different FPM socket. For example, site A can use PHP 8.1 while site B uses PHP 8.3.

Do PHP CLI and PHP-FPM need to be the same version?

No. PHP CLI is used for scripts run via terminal, while PHP-FPM handles web requests. Your website uses the version specified by the FPM socket that Nginx/Apache points to.

Can I delete the old PHP version right after upgrading?

Yes, once you're confident everything is working normally. It's recommended to wait 1–2 weeks before removing:

apt remove php8.1 php8.1-fpm php8.1-*
apt autoremove