Effortless Guide to Upgrade PHP to Version 8.4 on Ubuntu
Is your Ubuntu server still running PHP 7.x or 8.0/8.1/8.2? Upgrading to PHP 8.4 delivers improved performance, enhanced typing features, better syntax, bug fixes, and more robust security. Whether your server is on AWS, Azure, GCP, or a private cloud, this walkthrough shows you how to upgrade smoothly.
What’s New in PHP 8.4?
Enhanced readonly classes and properties
Improved type system & more stable union types
Performance optimizations and reduced memory overhead
Newly introduced functions and deprecations of unsafe or legacy code
Extended support and security patches
Step-by-Step: Upgrade to PHP 8.4 on Ubuntu
Prerequisites
Before you begin:
You have sudo or root access on your Ubuntu server
SSH access or terminal access
Backup of existing code/configuration in case you need to rollback
Test environment (if possible), especially for live/production servers
Note: If you use a web server like Apache, you may need php8.4-apache2 or equivalent. For Nginx + PHP-FPM, ensure your FPM pool is configured correctly.
4. Switch to PHP 8.4 (Disable Older Version, Enable 8.4)
If you’re using Apache:
sudo a2dismod php8.0 # or php8.1, etc., whatever version is currently active
sudo a2enmod php8.4
sudo service apache2 restart
If using Nginx + PHP-FPM, update your site config to point to the PHP 8.4 FPM socket and restart both Nginx and php8.4-fpm:
5. Configure the CLI PHP Version (if you use php in terminal)
If the php -v command still shows an old version:
sudo update-alternatives --config php
Choose the version showing /usr/bin/php8.4 (or similar). Also update phpize, php-config if needed.
6. Verify That PHP 8.4 Is Running Properly
php -v
Expected output should include something like:
PHP 8.4.x (cli) (built: …)
…
Also check:
Web-site pages (if CMS like WordPress / Laravel etc.) — ensure no errors
phpinfo() in browser (create a file with <?php phpinfo(); ?>)
Error logs for both PHP-FPM or Apache/Nginx
7. Post-Upgrade Cleanup & Best Practices
Remove unused or deprecated modules you no longer need
Check configuration files (e.g. php.ini) for new settings or changes introduced in PHP 8.4
Test your application thoroughly — issues like deprecated functions, strict typing, etc., may surface
Keep backups ready in case rollback is necessary
Troubleshooting Common Issues
Problem
Solution
Some module not found / extension missing
Install via apt install php8.4-<module>
Web server still shows old version
Disable old PHP module, enable new one, restart web server, check update-alternatives
Permissions / socket issues with PHP-FPM
Check ownership/group of FPM socket; match Nginx/Apache configuration
Conclusion
Upgrading to PHP 8.4 on Ubuntu is highly recommended for better security, modern features, and performance improvements. With careful preparation and following the steps above, you can upgrade smoothly with minimal downtime.
If you need help with custom configuration, module compatibility, or migration issues, feel free to reach out.