Diagnosing Disabled SOAP Extensions on CentOS
When you run yum install php-soap on a CentOS system and receive confirmation that the package is installed, it is tempting to assume functionality is ready. However, PHP extensions do not automatically activate merely by being present in the filesystem. The error Fatal error: Class 'SoapClient' indicates that while the RPM package exists, the PHP runtime cannot find the compiled shared object file required to instantiate the SOAP classes.
The root cause in your specific scenario lies in how CentOS 6 handles the Apache module loading system versus the standard PHP configuration file. You attempted to add extension=soap.so directly to a php.ini file, but this approach often fails on RPM-based distributions where the extension is managed by the package manager's .modinfo files rather than a central config file you can easily edit.
The CentOS 6 Module Loading Mechanism
On CentOS 6 (and similar RHEL variants), Apache uses the LoadModule directive in the main configuration file, typically located at /etc/httpd/conf.modules.d/. When you install php-soap via yum, the RPM package installs a corresponding module file, often named something like 20soap.conf within the conf.modules.d directory.
If this file is missing, it means the Apache server was not instructed to load the extension during startup. The command service httpd restart only reloads the current configuration; it cannot create new modules that are absent from the module list. To fix this, you must ensure the module file exists and is active.
Check for the existence of the configuration file:
ls -l /etc/httpd/conf.modules.d/
If 20soap.conf or a similarly named file is missing, it usually indicates that the package did not create the expected files, or your PHP installation is custom-built and does not align with the system RPM. If you are using the default Apache setup provided by CentOS 6, the cleanest solution is to verify if the module needs to be manually loaded in the main httpd.conf.
Verifying the Extension Path
Even if the module file exists, PHP must know where to find the shared object. The line extension=soap.so assumes the file resides in the default php.ini search path or a specific directory you pointed to. On CentOS 6, extensions are often loaded via directives in /etc/httpd/conf.d/.
You should check if the extension is being referenced in the Apache configuration rather than a standalone PHP config file. Look for lines resembling:
LoadModule php5_module modules/libphp.so
And ensure that the SOAP module is explicitly loaded. If you are using php.ini, verify its location by running:
php -i | grep "Loaded Configuration File"
If you edited a custom php.ini but Apache is ignoring it, your changes will have no effect. The extension directive must match the actual filename of the compiled library. On CentOS 6, this file is often named libphp5.so, not soap.so. You may need to adjust your configuration line to:
extension=soap.so
Only if soap.so actually exists in the zend_extensions_dir or the standard extension_dir. You can find the correct path by running:
find /usr -name "soap.so" 2>/dev/null
If this returns no results, the package installation did not place the library file where PHP expects it.
Rebuilding with Custom Options
Your attempt to reconfigure PHP using php-config suggests you are building PHP from source or attempting to override system defaults. This is a high-risk strategy on CentOS unless you have a specific reason to compile PHP outside of the RPM ecosystem. Mixing system-managed extensions like php-soap with custom-compiled PHP versions often leads to library mismatches and path conflicts.
The flags you used, such as --enable-soap, are correct for enabling the extension during compilation. However, if you are already using the system-installed php-soap package, recompiling PHP is unnecessary and likely counterproductive. The system package manages dependencies and ensures the shared library matches the Apache version installed by the OS.
If you must use a custom build, ensure that the --enable-soap flag is included and that the resulting libphp.so contains the SOAP module. You can verify this by listing the symbols in the compiled module before restarting Apache.
Conclusion
The persistence of the SoapClient fatal error after installing the package and editing a config file points to a missing or unloaded Apache module definition. On CentOS 6, the most reliable fix is to ensure the LoadModule directive for PHP SOAP is present in your Apache configuration or that the extension is correctly referenced via extension=soap.so in the active php.ini. Avoid mixing system RPM packages with custom-compiled PHP unless you fully understand the dependency implications. Once the module is loaded and the path is correct, restarting the service should resolve the error.
