The Package Manager Paradox on CentOS 6
When attempting to extend PHP functionality on legacy CentOS systems, you often encounter a specific friction point: the availability of tools versus the availability of packages. A common scenario involves trying to install a PECL extension like php_http (now known as pecl_http) on CentOS 6. You might successfully install PEAR and verify that the CLI tool exists, yet fail immediately when attempting to install a new package via yum or pecl.
The root cause usually lies in the distinction between installed binaries and repository availability. In your specific case, running yum install php-pear fails with "No package available," while pear commands work perfectly. This indicates that the PEAR/PECL tooling is already present on the system, likely installed manually or via a previous installation cycle, but the underlying PHP modules required by the PECL installer are missing from your configured repositories.
The error message returned by pecl install pecl_httpâ"No releases available for package 'pecl.php.net/pecl_http'"âis technically accurate but misleading in this context. It does not mean the repository doesn't exist; it means the PECL tool cannot find a compatible source tarball for your specific PHP version, or the local php-devel headers are missing, causing the build process to abort before downloading.
Diagnosing the Environment
Before attempting to rebuild sources, you must verify the state of your development environment. The most critical missing component is usually the development headers for PHP. PECL extensions require these headers to compile against your installed PHP version. If php-devel (or php-devel.x86_64) is not installed, the PECL tool cannot configure or build the extension, often resulting in confusing download errors.
Run the following command to check and install the necessary development packages:
yum install php-devel php-pear
Note that on CentOS 6, you must ensure your repositories are correctly configured. You mentioned using rpmforge, epel, and standard base/updates. The presence of vz-base and vz-updates suggests a virtualization host environment (likely Virtualmin or similar). These custom repos can sometimes obscure standard packages if they don't contain the specific version your PHP binary expects.
Resolving the Repository Conflict
A key observation in your logs is that /usr/bin/pecl is not a directory, yet pecl commands work. This confirms the PECL tool is installed. However, yum install pecl failing suggests a conflict between the system package manager and the manually installed PECL instance.
If you have manually installed PEAR/PECL (common on older CentOS setups), mixing these with yum packages can lead to version mismatches. The pecl tool checks for local sources first. If the remote source fails, it looks for a .tar.gz file in the PECH channel.
To resolve this without breaking your existing setup:
- Verify PHP Version: Run
php -v. Ensure you are targeting a version that has active support from the PECL channel. CentOS 6 ships with older PHP versions (often 5.3, 5.4, or early 5.5) where many modern extensions have been moved to "stable" releases that may not appear in the default PECH stream. - Check Local Sources: Sometimes the extension is already compiled into the binary as a
.sofile but missing fromphp.ini. Check/usr/lib64/php/modules/or similar paths for existing.sofiles namedhttp*.so. If they exist, you may not need to install them via PECL; you simply need to enable them in your configuration. - Force a Clean Build: If the extension is truly missing, try specifying the channel explicitly when installing:
This bypasses the automatic channel lookup and forces PECL to download the specific tarball compatible with your PHP version.pecl install http://pecl.php.net/get/http-2.0.1.tgz
Final Configuration
Once the extension is successfully installed via pecl (or found in the module directory), you must ensure PHP recognizes it. Add the following line to your active php.ini:
extension=http.so
Restart your web server or FastCGI process manager (likely httpd or nginx-fcgi) to load the new module. Remember that on CentOS 6, security updates are infrequent, so relying on the default EPEL or RPMforge repositories for PECL extensions can be risky if they pull in incompatible dependencies.
If you are building a production stack and require specific HTTP handling logic, consider whether the php_http extension is strictly necessary or if modern alternatives like cURL or Guzzle (available via Composer) would provide a more maintainable solution for your application logic.