Step 1: Installing ImageMagick
ssh root@server
2. Navigate to the Source Directory:
cd /usr/local/src/
3. Download ImageMagick:
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
4. Extract the Archive:
tar zxvf ImageMagick.tar.gz
5. Configure and Install:
Navigate to the ImageMagick directory (the name might vary based on the version):
cd ImageMagick-*
Now, compile and install ImageMagick:
./configure make make install
6. Install Perl Module:
If you need PerlMagick, the Perl interface for ImageMagick, continue with these steps:
cd PerlMagick
perl Makefile.PL
make
make install
7. Confirm ImageMagick Installation:
Verify that ImageMagick is installed:
which convert
Expected output: /usr/local/bin/convert
Step 2: Installing Imagick PHP Extension
1. Download Imagick for PHP:
wget http://pecl.php.net/get/imagick-2.3.0.tgz
2. Extract the Archive:
tar -zxvf imagick-2.3.0.tgz
3. Navigate to the Imagick Directory:
cd imagick-2.3.0
4. Prepare Imagick for PHP:
phpize ./configure make make install
5. Update PHP Configuration:
Edit the php.ini
file used by your PHP installation. The location of this file can vary, but typically it's found in /usr/local/lib/php.ini
:
vi /usr/local/lib/php.ini
6. Add Imagick Extension:
In the php.ini
file, add the following line to enable the Imagick extension:
extension="imagick.so"
Save and close the file.
Step 3: Restart the Web Server
After updating the PHP configuration, restart Apache to apply changes:
/scripts/restartsrv_httpd
Conclusion
You've successfully installed ImageMagick and the Imagick PHP extension on your cPanel server. This setup allows you to leverage powerful image processing capabilities directly from PHP scripts. Test the installation by running a PHP script that utilizes Imagick functions to ensure everything is working correctly. Remember to regularly update both ImageMagick and the Imagick extension to maintain security and functionality.