Quick Answer

Resolve PECL/extension installation problems.

Understanding the Issue

Common issues include missing dependencies, compiler errors, or PHP version mismatches.

The Problem

This code demonstrates the issue:

Bash Error
# pecl install redis
Failed to install

The Solution

Here's the corrected code:

Bash Fixed
# 1. Install dependencies
sudo apt install php-dev php-pear autoconf automake libtool

# 2. Specific package dependencies (example for redis)
sudo apt install pkg-config libssl-dev

# 3. Force rebuild
pecl install -f redis

# 4. Add extension to php.ini
echo "extension=redis.so" | sudo tee -a /etc/php/8.1/cli/php.ini

# 5. Verify
php -m | grep redis

# Alternative: Use package manager
sudo apt install php-redis

Key Takeaways

Ensure all build dependencies are installed before PECL installs.