Manually Installing the Imagick Extension for PHP 8.1 Print

  • 0

The Imagick extension is a powerful tool for handling images in PHP, leveraging the ImageMagick library. If you need to manually install Imagick for PHP 8.1, follow these steps.

Step 1: Download the Imagick Extension

First, download the latest stable version of the Imagick extension using PECL:

/opt/cpanel/ea-php81/root/usr/bin/pecl download imagick

This will retrieve the tarball file (e.g., imagick-3.7.0.tgz) in your current directory.

Step 2: Extract the Downloaded Archive

Once downloaded, extract the tar.gz archive:

 
tar -xzvf imagick-3.7.0.tgz

Navigate into the extracted directory:

cd imagick-3.7.0

Step 3: Prepare the Build Environment

Before compiling the extension, run phpize to prepare the build environment:

 
/opt/cpanel/ea-php81/root/usr/bin/phpize

Step 4: Configure and Compile the Extension

Next, configure the build process to use the correct PHP configuration file:

 
./configure --with-php-config=/opt/cpanel/ea-php81/root/usr/bin/php-config

Now, compile and install the extension:

 
make && make install

If everything goes well, you should see a success message indicating that imagick.so has been installed.

Step 5: Enable the Imagick Extension

To enable Imagick, edit the PHP configuration file for extensions:

 
nano /opt/cpanel/ea-php81/root/etc/php.d/zzzzzzz-pecl.ini

If the file is empty or doesn't exist, create it and add the following line:

echo "extension=imagick.so" >> /opt/cpanel/ea-php81/root/etc/php.d/zzzzzzz-pecl.ini

Verify the file contents:

nano /opt/cpanel/ea-php81/root/etc/php.d/zzzzzzz-pecl.ini

Ensure that the line extension=imagick.so is present.

Step 6: Restart Apache

For the changes to take effect, restart the Apache web server:

service httpd restart

Step 7: Verify Installation

Finally, confirm that Imagick is installed and enabled:

 
/opt/cpanel/ea-php81/root/usr/bin/php -m | grep imagick

If the command returns imagick, the installation was successful.


Final Thoughts

This guide walks you through manually compiling and enabling Imagick on a cPanel server running PHP 8.1. If you face issues, ensure that ImageMagick is installed on your server using:

 
yum install ImageMagick ImageMagick-devel -y

You can also check for missing dependencies with:

ldd /opt/cpanel/ea-php81/root/usr/lib64/php/modules/imagick.so

By following these steps, you’ll have Imagick fully functional in PHP 8.1, allowing you to manipulate images effortlessly within your applications.


Was this answer helpful?

« Back