Print

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

Unleashing Image Processing Power: Install the Imagick PHP Extension via SSH

Imagick is a powerful PHP extension that provides a comprehensive suite of image manipulation functionalities. It allows you to perform tasks like resizing, cropping, converting, and adding effects to images directly within your PHP applications. While many web hosting control panels offer simplified Imagick installation methods, sometimes you might need to install it manually via SSH, especially if you have a dedicated server or a VPS without a control panel. This guide provides a step-by-step walkthrough of how to install the Imagick PHP extension using SSH, empowering you to harness its image processing capabilities.

Why Use the Imagick PHP Extension?

Imagick offers numerous benefits for web developers and website owners:

  • Extensive Image Manipulation: Perform a wide range of image editing tasks, including resizing, cropping, rotating, adding watermarks, and applying filters.
  • Improved Website Performance: Optimize images for web use, reducing file sizes and improving loading speeds.
  • Enhanced User Experience: Create visually appealing images and dynamic graphics to enhance user engagement.
  • Increased Flexibility: Integrate image processing directly into your PHP applications, providing greater control and customization.

Prerequisites

Before you begin the installation process, ensure you have the following:

  • SSH Access: You’ll need SSH access to your server to execute the necessary commands.
  • Root or Sudo Privileges: You’ll need root or sudo permissions to install packages and modify system files.
  • Text Editor: You’ll need a text editor (like nano or vim) to edit the PHP configuration file.

Installing Imagick via SSH

Step 1: Connect to Your Server via SSH

  1. Open Terminal: Open a terminal window on your local computer.

  2. Establish SSH Connection: Use the following command to connect to your server via SSH, replacing your_server_ip with your server’s actual IP address or hostname:

    ssh root@your_server_ip 
  3. Enter Password: Enter your server’s root password when prompted.

Step 2: Check Your PHP Version

Determine the PHP version installed on your server by running the following command:

php -v

Make a note of the PHP version, as you’ll need it in the next step.

Step 3: Install ImageMagick and Imagick

Use your server’s package manager to install the necessary packages. The commands may vary slightly depending on your operating system.

For CentOS/AlmaLinux (using yum):

sudo yum install ImageMagick ImageMagick-devel
sudo pecl install imagick

For Ubuntu/Debian (using apt):

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

Step 4: Enable the Imagick Extension

  1. Locate PHP Configuration File: The location of your PHP configuration file (php.ini) may vary depending on your PHP version and operating system. A common location is /etc/php/7.4/cli/php.ini (replace 7.4 with your actual PHP version).

  2. Edit php.ini: Use a text editor to open the php.ini file:

    sudo nano /etc/php/7.4/cli/php.ini
    
  3. Add Extension: Add the following line to enable the Imagick extension:

    extension=imagick.so
    
  4. Save and Exit: Save the php.ini file and exit the text editor.

Step 5: Restart Your Web Server

Restart your web server to apply the changes. The command may vary depending on your web server software.

For Apache:

sudo systemctl restart apache2

For Nginx:

sudo systemctl restart nginx

Step 6: Verify Imagick Installation

  1. Create a PHP Info File: Create a PHP file named info.php in your website’s root directory with the following content:

    <?php
    phpinfo();
    ?>
    
  2. Access the File: Open a web browser and visit your-domain.com/info.php (replace your-domain.com with your actual domain name).

  3. Search for Imagick: Use your browser’s “Find” function (usually Ctrl+F or Cmd+F) to search for “imagick” on the page. If Imagick is installed correctly, you’ll see a section with details about the extension.

MyGlobalHost: Simplifying Imagick Installation

While manual installation via SSH provides flexibility, it can be technically challenging for some users. MyGlobalHost offers managed hosting solutions where our expert support team can assist you with installing and configuring the Imagick PHP extension, ensuring a hassle-free experience.

Choose MyGlobalHost for reliable, high-performance hosting solutions and expert support.

Table of Contents
Close
Get 75% + extra 10% Discount on web Hosting Plans by myglobalHOST

Extra 10% OFF

Coupon Code

EXTRA10

Applicable on

FLAT Rs 100 OFF

Coupon Code

FLAT100

Applicable on

How to Avail: Simply browse the most appropriate hosting plan for you and avail extra discount on all orders.

Expert Advice

+91-79862-84663

11AM to 6PM

Live Chat : 11AM to 6PM