All Hosting Plan Are Also Available On Monthly, Quarterly And Semi-Annually.
< All Topics
Print

How to install Imagick PHP extension

Method 1: Installing via PECL (Recommended)

This is the standard and most reliable method for installing PHP extensions from the command line.

1. Install Required Dependencies: First, you need to ensure you have the necessary development tools and libraries for Imagick. The commands for this depend on your OS:

  • For CentOS/RHEL/CloudLinux:
    Bash
    sudo yum install ImageMagick ImageMagick-devel gcc php-devel php-pear
    
  • For Ubuntu/Debian:
    Bash
    sudo apt-get install imagemagick imagemagick-doc php-pear php-dev
    

2. Install Imagick using PECL: Next, use the pecl command to download and compile the Imagick extension.

Bash
sudo pecl install imagick

You may be prompted to enter a path for ImageMagick’s config file. In most cases, you can just press Enter to accept the default.

3. Enable the Extension: After the installation is complete, you need to tell PHP to load the new extension. You do this by adding a line to your php.ini file.

  • Find your php.ini file. The location can vary, but it’s often in /etc/php.ini or within a version-specific folder like /etc/php/7.4/cli/php.ini. You can find it by running:
    Bash
    php -i | grep "Loaded Configuration File"
    
  • Open the php.ini file with a text editor like nano or vi:
    Bash
    sudo nano /etc/php.ini
    
  • Add the following line to the end of the file:
    Ini, TOML
    extension=imagick.so
    
  • Save and close the file.

4. Restart the Web Server: Finally, restart your web server so that the changes to php.ini take effect.

  • For Apache:
    Bash
    sudo systemctl restart httpd
    

    or

    Bash
    sudo systemctl restart apache2
    
  • For Nginx (with PHP-FPM):
    Bash
    sudo systemctl restart php-fpm
    

Method 2: Installing on a cPanel/WHM Server

If you are on a cPanel server, the recommended way to install PHP extensions is through WHM’s EasyApache 4 interface. This ensures the extension is properly configured for all your PHP versions.

1. Log in to WHM: Access your WebHost Manager as the root user.

2. Go to EasyApache 4: In the search bar, type EasyApache 4 and click on the corresponding link.

3. Customize Your Profile: On the EasyApache 4 page, find the “Currently Installed Packages” profile and click the Customize button.

4. Search for Imagick: Navigate to the PHP Extensions section, and in the search box, type imagick.

5. Provision the Extension: Check the box next to imagick and any other required dependencies. Click the Review button, and then click Provision to compile and install the extension. This process will automatically restart Apache and enable Imagick for all selected PHP versions.

Table of Contents

Windows Hosting is comming soon. All Hosting Plan Are Also Available On Monthly, Quarterly And Semi-Annually.

Call back request.