Search Knowledge Base
Table of Contents
< Go Back To Home

How to install Imagick PHP extension (From SSH / Terminal)

Sometimes installing Imagick PHP extension requires SSH or Terminal access to your server because it requires root or sudo permissions and becomes mandatory if you do not have any control panel installed like cPanel. However, you can request your hosting provider’s support also to install it for you if you’re using a managed hosting server. Here’s a general guideline on how to install and enable Imagick php extension on your linux server:

Important Note: Please make sure you have Terminal Root / SSH access and the necessary permissions to install PHP extensions.

Login via SSH Access:

Log in to your server via SSH using your terminal or an SSH client like PuTTY.

Check PHP Version:

Determine which PHP version you’re using. You can do this by running the following command:

php -v

Make note of the PHP version as you’ll need it in the following steps.

Installing Imagick:

You can use a package manager like ‘yum’ or ‘apt’ to install Imagick. The command may vary depending on your server’s operating system.

For CentOS/AlmaLinux (using ‘yum’):

sudo yum install ImageMagick ImageMagick-devel
sudo pecl install imagick

or Ubuntu/Debian (using ‘apt’):

sudo apt-get install imagemagick libmagickwand-dev
sudo pecl install imagick

Enable Imagick Extension:

Edit the PHP configuration file. The path may vary depending on your PHP version. For example, for PHP 7.4, the file is typically located here: (Use nano command to open editor in terminal / ssh)

sudo nano /etc/php/7.4/cli/php.ini

Add the following line to enable the Imagick extension:

Save the file and exit.

Restart PHP:

Restart your web server or PHP service to apply the changes:

For Apache:

sudo systemctl restart apache2

For Nginx:

sudo systemctl restart nginx

Verify Installation:

To verify that Imagick is installed correctly, create a PHP file (e.g., info.php) in your web directory with the following content:


Access this file through a web browser and search for the “imagick” section. If it appears, Imagick is successfully installed.

Please note that the specific commands and paths may vary depending on your server’s configuration, PHP version, and operating system. If you’re unsure about any step, it’s recommended to contact your hosting provider’s support for assistance with installing the Imagick PHP extension.