Resolving the php-mbstring Dependency Conflict on CentOS 7
You are encountering a classic RPM dependency hell scenario where the package manager refuses to install php-mbstring because of a version mismatch in its required shared libraries. The error log explicitly states that php-mbstring-5.4.16-23.el7_0.3 requires php-common(x86-64) = 5.4.16-23.el7_0.3, yet your system currently holds php-common-5.4.38-1.el7.remi. The core issue is not a missing package, but a version skew between the main PHP installation and the Remi repository's packages.
The php-mbstring extension from the Remi repository depends on a specific build of the php-common library that matches its own versioning scheme. Your system has installed a newer version of php-common (5.4.38) directly from the Remi repo, likely as part of a previous installation or update, which broke the strict equality constraint for the older php-mbstring build. When you attempt to install the extension, the transaction manager detects that the available php-common packages do not satisfy the exact version requirement 5.4.16-23.el7_0.3.
To resolve this without forcing a full system re-installation or breaking your existing PHP environment, you need to align the package versions. The most direct approach is to ensure that all Remi PHP packages are from the same release cycle. Since you have php-common at version 5.4.38, your php-mbstring needs to match that specific build string.
You can check which version of php-mbstring corresponds to your installed php-common by querying the Remi repository metadata:
rpm -qa php-mbstring | grep remi
rpm -q php-common
If the versions still do not align, you may need to remove the conflicting php-mbstring package if it exists partially, or force an upgrade of the base php-common to match the one required by the specific php-mbstring build you intend to install. However, a cleaner solution often involves ensuring that the Remi repository is fully synchronized for the PHP 5.4 branch.
Run the following command to update all packages from the Remi repository while skipping broken dependencies temporarily to see what resolves automatically:
sudo yum --skip-broken update php-common php-mbstring
If --skip-broken cannot find a valid transaction, the issue is likely that your PHP stack is a mix of base repo and Remi repo versions. In this specific error case, the system has a very old version of php-common (5.4.16) available in the updates or base repository, while you have an older but newer 5.4.38 from Remi. The strict equality check = 5.4.16-23.el7_0.3 suggests that the package manager is looking for a very specific build number of the common library that might not be available or has been superseded.
The definitive fix is to remove the conflicting php-common version and let the Remi repository provide a consistent set of libraries. You can attempt to force the removal of the current php-common and reinstall the PHP stack from the Remi source:
sudo yum remove php-common-5.4.38-1.el7.remi.x86_64
sudo yum install epel-release # Ensure EPEL is present if needed for remi dependencies
sudo yum --enablerepo=remi install php-mbstring php-common
Be cautious when mixing PHP versions from different repositories. If you are running a specific version of PHP (like 5.4) alongside others, ensure that the php-cli, php-fpm, and php-common all come from the same source to avoid further dependency breaks. The Remi repository is excellent for providing newer extensions on CentOS 7, but it requires strict adherence to its own package versions.
If you are maintaining a legacy application requiring PHP 5.4, consider checking if a newer patch version of php-mbstring exists in the Remi repo that matches your current php-common. If no matching build exists, you may need to compile the extension from source against your existing php-common headers to ensure binary compatibility. This is more complex but guarantees that the shared object file links correctly with the installed library.
For production environments where stability is paramount, avoiding mixed repository versions is a best practice. If you rely on specific extensions like mbstring for handling multibyte characters in your application logic, ensuring the underlying php-common library is consistent prevents subtle runtime errors or segmentation faults that package managers might not immediately flag.
If you are using Laravel or other modern frameworks on this legacy OS, remember that PHP 5.4 is end-of-life and lacks support for many modern security updates and language features. While solving this specific dependency error restores functionality, the long-term strategy should involve migrating to a supported PHP version like 7.4 or 8.x, where these strict versioning conflicts are less common due to updated packaging standards.
