When trying to install the Imagick PHP extension via PECL on Ubuntu, many developers encounter the frustrating error message about missing MagickWand configuration. This typically occurs because while ImageMagick is installed, the development headers needed for compiling PHP extensions aren't present.
Here's the proper way to install Imagick with all dependencies:
sudo apt-get update
sudo apt-get install -y php-dev php-pear libmagickwand-dev
sudo apt-get install -y imagemagick
sudo pecl install imagick
After successful installation, add the extension to your PHP configuration:
echo "extension=imagick.so" | sudo tee /etc/php/5.2/mods-available/imagick.ini
sudo php5enmod imagick
sudo service apache2 restart
If you still face issues, check these points:
- Ensure PHP development tools are installed:
sudo apt-get install php5-dev
- Verify ImageMagick version compatibility:
convert --version
- Check for multiple PHP versions:
update-alternatives --config php
For newer Ubuntu versions, you can install directly from packages:
sudo apt-get install php-imagick
When compilation fails, examine the full output carefully. The key configuration check should show:
checking for MagickWand.h header file... found in /usr/include/ImageMagick-6
If this fails, manually specify the path during PECL installation:
sudo pecl install --with-imagick=/usr/include/ImageMagick-6 imagick
When attempting to install the Imagick PHP extension via PECL on Ubuntu, many developers encounter the frustrating error message:
checking ImageMagick MagickWand API configuration program...
configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
This typically occurs when the system can't locate the necessary ImageMagick development files required for compiling the PHP extension.
Here's the complete set of commands to properly install Imagick with all dependencies:
sudo apt-get update
sudo apt-get install -y php-dev php-pear libmagickwand-dev
sudo pecl install imagick
echo "extension=imagick.so" | sudo tee /etc/php/5.2/mods-available/imagick.ini
sudo php5enmod imagick
sudo service apache2 restart
The key package that was missing in the original scenario is libmagickwand-dev
. This provides:
- The MagickWand-config utility
- Development headers for ImageMagick
- Necessary libraries for compilation
For older PHP versions (like 5.2.4 mentioned in the question), you might need to specify an older Imagick version:
sudo pecl install imagick-2.3.0
Create a test PHP file with this content:
<?php
phpinfo();
?>
Then check for the Imagick section in the output, which should show:
- Imagick module version
- ImageMagick version number
- Supported image formats
If PECL installation still fails, try the Ubuntu package:
sudo apt-get install php-imagick
This provides a precompiled version that typically works better with the system's package manager.
- Not running
apt-get update
before installation - Missing the
php-dev
package - Forgetting to enable the extension after installation
- Not restarting the web server