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 -v

Explanation: 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 -y

Explanation:

  • sudo runs the command with elevated privileges.

  • dnf is the package manager used on Oracle Linux.

  • update php checks for an applicable update to the PHP package.

  • -y automatically 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 -y

The 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.bak

This copies the main PHP configuration file.

sudo cp -r /etc/php-fpm.d /etc/php-fpm.d.bak

This 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.d

Explanation:

  • tar creates an archive.

  • -c creates a new archive.

  • -z compresses the archive with gzip.

  • -f specifies 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 php

This 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 --enabled

If 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.2

This 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 all

This removes cached DNF repository data.

Next, run:

sudo dnf makecache

This 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-opcache

Explanation:

  • --disablerepo='ol9_appstream' temporarily disables the Oracle Linux AppStream repository for this command.

  • --enablerepo=remi-modular,remi-safe enables the specified Remi repositories for this command.

  • list displays package information.

  • --showduplicates lists multiple available versions.

  • php, php-cli, php-common, php-fpm, and php-opcache are 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:

ComponentBeforeAfter
PHP8.2.278.2.35
PHP CLI8.2.278.2.35
PHP-FPM8.2.278.2.35
PHP OPcache8.2.278.2.35
PHP ZIP extension1.22.41.22.8
Phalcon5.8.05.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.rpmnew

Compare the existing and new files:

sudo diff -u /etc/php.d/50-phalcon.ini \
  /etc/php.d/50-phalcon.ini.rpmnew

Review the differences before merging configuration changes. Do not blindly overwrite the current configuration.

11. Verify the PHP Version

php -v

In 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 phalcon

This 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-phalcon5

The 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-pager

This 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-fpm

If approved, configure automatic startup with:

sudo systemctl enable php-fpm

15. Validate PHP-FPM Configuration

sudo php-fpm -t

This tests PHP-FPM configuration syntax.

Then check whether the service is running:

sudo systemctl is-active php-fpm

For recent PHP-FPM service logs, run:

sudo journalctl -u php-fpm -n 50 --no-pager

Review 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:

  1. Whether the correct repositories are enabled.

  2. Whether repository metadata is current.

  3. Whether the required PHP module stream is selected.

  4. Whether newer versions are available from the approved repository.

  5. Whether installed extensions have their own package updates.

Useful commands include:

sudo dnf repolist --all

Lists configured repositories and their status.

sudo dnf makecache

Refreshes repository metadata.

sudo dnf list --showduplicates php

Lists available versions of the PHP package.

sudo dnf check-update

Checks 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 .rpmnew files 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

Popular posts from this blog

How to install VNX Launcher that has embedded java and Firefox

DHCP FAILED APIPA IS USED

Zabbix Server is not working: the information dispaly may not be current