I have searched a lot, and also been getting help in these forums, and here I have a complete guide that I can guarantee that will work. However, this is only tested on servers running CentOS 6.x with PHP as suPHP/CGi, however it should be similar on other systems.
Some notes is that ImageMagick and ImageMagick-devel need to be the same versions. Other note is that ImageMagick-devel should NOT be installed using yum, instead install it using rpm without installing any dependency, afterwords we will remove ImageMagick-devel wich is only needed during install.
So here we go, installing ImageMagick and Imagick from source on CentOS 6.3x:
1: Install ImageMagick and ImageMagick-devel using yum because we need all the dependency installed:
2: Remove ImageMagick and ImageMagick-devel using yum:
3: Download tar.gz from http://www.imagemagick.org/script/download.php - for example we can choose from United States, like I will do in this example:
4: No wee need to install ImageMagick-devel without yum (because we do not want the dependency to be installed). Find the newest version from (this is for CentOS 64bit, also version must be same as ImageMagick version you install previously) http://www.imagemagick.org/download/linux/CentOS/x86_64/ and install it like this:
5: We are now ready to install Imagick php module. Do it like this:
Look at the result, and use the path in the following export path (modify according to your own path in above code). Here is the command that is correct for my path:
Then continue to install Imagick php module (Edit: If you are running php 5.4.x, then you need to install imagick 3.1.0RC2, 3.0.1 will give errors, find it here: http://pecl.php.net/package/imagick ):
6: Next we edit /usr/local/etc/php5/cgi/php.ini (adjust according to your own php.ini path) and add extension. Add this to bottom of your php.ini file:
Then restart apache:
7: Now we should remove ImageMagick-devel wich is no longer needed:
And then we can delete all the not needed files in /root, you can delete these:
8: Finally if you use suPHP, we need to edit suphp.conf files so that commands like "convert" will work in php without the need to use full path in the commands. Every time you recompile php, you must add back the change in suphp.conf file. Do it like this:
Edit this file: /usr/local/suphp/etc/suphp.conf - find line number 32 wich looks like this:
Replace that line with this:
Then restart apache:
Now you can do some tests. First chech a php.info file to see everything is there. Then you can upload a php file to your website with this content:
If it works, it will print out the convert path in the page when you view it in a browser. Also, here is some other commands to test in command line that everything looks good and is working:
This will create a logo.gif file in root/logo.gif:
Some more commands to test in command line:
I spent a lot of time before I had every problem fixed, and this guide should be perfect for you if you run same system as I do, and want the source install of ImageMagick and Imagic. Follow same steps when upgrading, only you can skip doing step 1 and step 2. Enjoy!
Edit: If you are upgrading image magick from previous version, remember to run ldconfig /usr/local/lib or just ldconfig at root level of server - thanks to Trans-IX B.V
Edit: I edited step 5 with this information: If you are running php 5.4.x, then you need to install imagick 3.1.0RC2, 3.0.1 will give errors, find it here: http://pecl.php.net/package/imagick
Edit: I have removed --with-modules from configure command in step 3 to solve this problem: http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=22223
Edit: As of ImageMagick version 6.8.3-0 it is now needed to have the perl module parent installed, you can install parent using cpan:
Edit: If you in "Step 5" when doing ./configure get this error: checking for MagickWand.h header file... configure: error: Cannot locate header file MagickWand.h - then it is because of change in newer versions folder name and because imagick has hardcoded the folder name, you can fix it by doing as described in post #13 here http://forum.directadmin.com/showthread.php?t=45957&p=238929#post238929
Some notes is that ImageMagick and ImageMagick-devel need to be the same versions. Other note is that ImageMagick-devel should NOT be installed using yum, instead install it using rpm without installing any dependency, afterwords we will remove ImageMagick-devel wich is only needed during install.
So here we go, installing ImageMagick and Imagick from source on CentOS 6.3x:
1: Install ImageMagick and ImageMagick-devel using yum because we need all the dependency installed:
Code:
yum install ImageMagick
yum install ImageMagick-devel
2: Remove ImageMagick and ImageMagick-devel using yum:
Code:
yum remove ImageMagick
yum remove ImageMagick-devel
3: Download tar.gz from http://www.imagemagick.org/script/download.php - for example we can choose from United States, like I will do in this example:
Code:
cd /root
wget http://imagemagick.mirrorcatalogs.com/ImageMagick-6.7.9-2.tar.gz
tar zxf ImageMagick-6.7.9-2.tar.gz
cd ImageMagick-6.7.9-2
./configure --with-perl=/usr/bin/perl
make
make install
4: No wee need to install ImageMagick-devel without yum (because we do not want the dependency to be installed). Find the newest version from (this is for CentOS 64bit, also version must be same as ImageMagick version you install previously) http://www.imagemagick.org/download/linux/CentOS/x86_64/ and install it like this:
Code:
cd /root
rpm -i --nodeps http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-devel-6.7.9-2.x86_64.rpm
5: We are now ready to install Imagick php module. Do it like this:
Code:
find / -name phpize
Code:
export PATH=$PATH:/usr/local/php5/bin
Then continue to install Imagick php module (Edit: If you are running php 5.4.x, then you need to install imagick 3.1.0RC2, 3.0.1 will give errors, find it here: http://pecl.php.net/package/imagick ):
Code:
cd /root
wget http://pecl.php.net/get/imagick-3.0.1.tgz
tar zxf imagick-3.0.1.tgz
cd imagick-3.0.1
phpize
./configure
make
make install
6: Next we edit /usr/local/etc/php5/cgi/php.ini (adjust according to your own php.ini path) and add extension. Add this to bottom of your php.ini file:
Code:
extension=imagick.so
Then restart apache:
Code:
service httpd restart
7: Now we should remove ImageMagick-devel wich is no longer needed:
Code:
yum remove ImageMagick-devel
And then we can delete all the not needed files in /root, you can delete these:
Code:
ImageMagick-6.7.9-2
imagick-3.0.1
ImageMagick-6.7.9-2.tar.gz
imagick-3.0.1.tgz
8: Finally if you use suPHP, we need to edit suphp.conf files so that commands like "convert" will work in php without the need to use full path in the commands. Every time you recompile php, you must add back the change in suphp.conf file. Do it like this:
Edit this file: /usr/local/suphp/etc/suphp.conf - find line number 32 wich looks like this:
Code:
env_path="/bin:/usr/bin"
Replace that line with this:
Code:
env_path="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
Then restart apache:
Code:
service httpd restart
Now you can do some tests. First chech a php.info file to see everything is there. Then you can upload a php file to your website with this content:
Code:
<?php
echo "<pre>";
system("which convert");
echo "</pre>";
?>
If it works, it will print out the convert path in the page when you view it in a browser. Also, here is some other commands to test in command line that everything looks good and is working:
This will create a logo.gif file in root/logo.gif:
Code:
cd /root
/usr/local/bin/convert logo: logo.gif
Some more commands to test in command line:
Code:
php -m | grep imagick
identify -version
which convert
/usr/local/bin/identify -list format
/usr/local/bin/identify -list configure
I spent a lot of time before I had every problem fixed, and this guide should be perfect for you if you run same system as I do, and want the source install of ImageMagick and Imagic. Follow same steps when upgrading, only you can skip doing step 1 and step 2. Enjoy!

Edit: If you are upgrading image magick from previous version, remember to run ldconfig /usr/local/lib or just ldconfig at root level of server - thanks to Trans-IX B.V
Edit: I edited step 5 with this information: If you are running php 5.4.x, then you need to install imagick 3.1.0RC2, 3.0.1 will give errors, find it here: http://pecl.php.net/package/imagick
Edit: I have removed --with-modules from configure command in step 3 to solve this problem: http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=22223
Edit: As of ImageMagick version 6.8.3-0 it is now needed to have the perl module parent installed, you can install parent using cpan:
Code:
cpan
install parent
Last edited: