How to Update PHP 8.2.27 to 8.2.35 to the Latest Version on Oracle Linux 9 (Step-by-Step Guide)
How to Update PHP on Oracle Linux 9 Using DNF | Step-by-Step Guide
Are you managing PHP applications on Oracle Linux 9? In this tutorial, we will learn how to check the installed PHP version, inspect available package versions, configure the Remi PHP module stream, back up configuration files, upgrade PHP packages, and validate PHP-FPM after the update.
This guide is useful for Linux administrators, system engineers, DevOps engineers, and beginners who want practical experience with Oracle Linux server administration.
What You Will Learn
How to check the current PHP version
How to check available PHP module streams
How to enable the Remi PHP 8.2 module stream
How to refresh DNF repository metadata
How to list available PHP package versions
How to back up PHP configuration files
How to preview a package upgrade safely
How to upgrade PHP and related extensions
How to verify PHP, Phalcon, and PHP-FPM
1. Check the Installed PHP Version
Run the following command:
php -vExplanation: This command displays the installed PHP CLI version, Zend Engine version, build details, and OPcache information.
In our example, the initial version was PHP 8.2.27. Always record the existing version before performing a software update.
2. Check for Available PHP Updates
sudo dnf update php -yExplanation:
sudoruns the command with elevated privileges.dnfis the package manager used on Oracle Linux.update phpchecks for an applicable update to the PHP package.-yautomatically confirms prompts.
If the output says Nothing to do, it means DNF did not find an applicable update for that package with the repository configuration and package-selection rules currently in effect. It does not necessarily mean every PHP extension is up to date.
You can also run:
sudo dnf upgrade php -yThe upgrade command performs the same general package-upgrade function in this scenario.
3. Back Up PHP Configuration Files
Before upgrading production software, create configuration backups.
sudo cp /etc/php.ini /etc/php.ini.bakThis copies the main PHP configuration file.
sudo cp -r /etc/php-fpm.d /etc/php-fpm.d.bakThis recursively copies the PHP-FPM pool configuration directory.
For a more complete configuration archive, use:
sudo tar -czf /root/php-config-backup-$(date +%F-%H%M).tar.gz \
/etc/php.ini /etc/php.d /etc/php-fpm.conf /etc/php-fpm.dExplanation:
tarcreates an archive.-ccreates a new archive.-zcompresses the archive with gzip.-fspecifies the archive filename.$(date +%F-%H%M)adds a date and time to the filename.
Keep backups in a secure location and verify that they contain the expected files.
4. List Available PHP Module Streams
sudo dnf module list phpThis command lists PHP module streams available from the configured repositories. Depending on repository configuration, you may see Oracle Linux streams such as PHP 8.1, 8.2, and 8.3, as well as Remi streams.
A module stream identifies a software version line that DNF can use when resolving packages.
To check enabled PHP module streams, run:
sudo dnf module list php --enabledIf no matching enabled stream is displayed, it does not automatically mean PHP is missing. The PHP executable and the module stream configuration are different things.
5. Enable the Remi PHP 8.2 Stream
If your application requires PHP 8.2 and the Remi repository is configured and approved, run:
sudo dnf module enable php:remi-8.2This enables the Remi PHP 8.2 module stream.
Important: Enabling a module stream does not itself upgrade installed PHP packages. It changes module-stream selection for subsequent package operations.
Review your application's compatibility requirements before changing module streams on a production server.
6. Refresh DNF Repository Metadata
sudo dnf clean allThis removes cached DNF repository data.
Next, run:
sudo dnf makecacheThis downloads and prepares repository metadata so DNF can query available packages.
If metadata downloads fail, investigate repository configuration, DNS, network access, HTTPS connectivity, proxy settings, and GPG configuration before proceeding.
7. List Available PHP Package Versions
The following command checks PHP package versions from the selected Remi repositories:
sudo dnf --disablerepo='ol9_appstream' \
--enablerepo=remi-modular,remi-safe \
list --showduplicates php php-cli php-common php-fpm php-opcacheExplanation:
--disablerepo='ol9_appstream'temporarily disables the Oracle Linux AppStream repository for this command.--enablerepo=remi-modular,remi-safeenables the specified Remi repositories for this command.listdisplays package information.--showduplicateslists multiple available versions.php,php-cli,php-common,php-fpm, andphp-opcacheare the packages being inspected.
In our example, PHP 8.2.27 was installed, while PHP 8.2.34 and 8.2.35 were available from the Remi modular repository.
The exact versions available will change over time.
8. Preview the Upgrade Before Applying It
Always review the proposed transaction before upgrading a production server.
sudo dnf upgrade --assumeno \
--disablerepo='ol9_appstream' \
--enablerepo=remi-modular,remi-safe \
'php*'The --assumeno option automatically declines the transaction confirmation. It allows you to inspect the proposed package changes without applying them.
The 'php*' pattern selects packages whose names start with php, subject to DNF's dependency and repository rules.
In our example, DNF proposed upgrading 15 PHP-related packages. The command ended with Operation aborted because the transaction was declined by --assumeno. This was the expected dry-run behavior.
9. Upgrade PHP and Related Packages
After reviewing the transaction and obtaining the necessary approval, run:
sudo dnf upgrade \
--disablerepo='ol9_appstream' \
--enablerepo=remi-modular,remi-safe \
'php*'Review the transaction summary before accepting it.
In our example, 15 packages were upgraded, including PHP, PHP CLI, PHP-FPM, OPcache, GD, GMP, MBString, MySQL support, PDO, ZIP, XML, and Phalcon.
The recorded version changes included:
| Component | Before | After |
|---|---|---|
| PHP | 8.2.27 | 8.2.35 |
| PHP CLI | 8.2.27 | 8.2.35 |
| PHP-FPM | 8.2.27 | 8.2.35 |
| PHP OPcache | 8.2.27 | 8.2.35 |
| PHP ZIP extension | 1.22.4 | 1.22.8 |
| Phalcon | 5.8.0 | 5.23.0 |
These are the versions from the example session, not a guarantee of the latest versions available today.
10. Review RPM Configuration Warnings
During an upgrade, RPM may create a file ending in .rpmnew when it cannot safely replace an existing configuration file.
For example, the transaction created:
/etc/php.d/50-phalcon.ini.rpmnewCompare the existing and new files:
sudo diff -u /etc/php.d/50-phalcon.ini \
/etc/php.d/50-phalcon.ini.rpmnewReview the differences before merging configuration changes. Do not blindly overwrite the current configuration.
11. Verify the PHP Version
php -vIn our example, the output confirmed PHP 8.2.35 after the upgrade.
This verifies the version reported by the PHP CLI executable.
12. Verify the Phalcon Extension
php --ri phalconThis command displays information about the Phalcon PHP extension.
In our example, the output confirmed that Phalcon was enabled and reported version 5.23.0.
If your application uses other PHP extensions, verify those extensions as well.
13. Verify Installed PHP RPM Packages
rpm -q php php-cli php-common php-fpm php-opcache php-phalcon5The rpm -q command queries the RPM package database and displays the installed versions of the named packages.
This provides package-level verification alongside the php -v executable check.
14. Check PHP-FPM Service Status
sudo systemctl status php-fpm --no-pagerThis displays the current PHP-FPM service state and recent service messages.
In our example, the service was active (running). However, the output also showed that it was disabled for automatic startup at boot.
These statuses are different:
Active: The service is currently running.
Enabled: The service is configured to start automatically during boot.
If PHP-FPM is required by your application, verify the intended startup policy with the system owner.
To check whether it is enabled:
sudo systemctl is-enabled php-fpmIf approved, configure automatic startup with:
sudo systemctl enable php-fpm15. Validate PHP-FPM Configuration
sudo php-fpm -tThis tests PHP-FPM configuration syntax.
Then check whether the service is running:
sudo systemctl is-active php-fpmFor recent PHP-FPM service logs, run:
sudo journalctl -u php-fpm -n 50 --no-pagerReview any errors or warnings, and test the actual web application using its normal URL.
Troubleshooting: Why Does DNF Say “Nothing to Do”?
If dnf update php reports Nothing to do, do not assume that every PHP component is current. Check:
Whether the correct repositories are enabled.
Whether repository metadata is current.
Whether the required PHP module stream is selected.
Whether newer versions are available from the approved repository.
Whether installed extensions have their own package updates.
Useful commands include:
sudo dnf repolist --allLists configured repositories and their status.
sudo dnf makecacheRefreshes repository metadata.
sudo dnf list --showduplicates phpLists available versions of the PHP package.
sudo dnf check-updateChecks for available package updates. Exit status 100 commonly means updates are available; interpret the output and exit status together.
Production Best Practices
Back up configuration files before patching.
Review the proposed DNF transaction before accepting it.
Use approved repositories and supported package streams.
Review
.rpmnewfiles instead of ignoring them.Verify PHP extensions required by the application.
Test PHP-FPM and application functionality after patching.
Document the change and retain validation evidence.
Conclusion
In this practical Oracle Linux example, we checked the PHP installation, examined module streams and package versions, backed up configuration, previewed the transaction, upgraded PHP-related packages, and verified PHP, Phalcon, and PHP-FPM.
The recorded PHP version changed from 8.2.27 to 8.2.35. Always validate the exact package versions and application behavior on your own server before declaring a patch successful.
Join Our IT Learning Community
Learn more about Linux administration, networking, Windows Server, VMware, and cybersecurity.
Telegram Community: https://t.me/sharankumatitacademy
Discord Community: https://discord.gg/wjxPWweer
Subscribe to the YouTube channel for practical IT tutorials and step-by-step demonstrations.
#OracleLinux #LinuxAdministration #PHP #DNF #PHPFPM #RemiRepository #LinuxTutorial #ServerAdministration #CyberSecurity
Comments
Post a Comment