ImageMagick-6.7.9-2 install

Status
Not open for further replies.
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:
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-modules --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
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:

Code:
export PATH=$PATH:/usr/local/php5/bin

Then continue to install Imagick php module:
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! :)
 
Last edited:
You my friend are Amazing taking the time writing this all down here for others to see.. Just have to say thank you very much! i owe you a cold one.
 
I am only happy to finally be able to give something back to the DirectAdmin community wich has helped me so many times in these forums. Please remember to follow every step. Please let me know if you have questions or problems. This guide should be complete without anything missing. Also I would like to try to explain something from the steps above:

The reason we need to install ImageMagick-devel using rpm and not install it using yum, is because when you install it with yum it will also install ImageMagick as a dependency, and that will break it because you are installing ImageMagick from source. And as you can see, ImageMagick-devel is needed to be able to install Imagick php module. But because of all this, it is important that you remove ImageMagick-devel using yum after you finish everything, if not yum might upgrade ImageMagick-devel in the future and then install ImageMagick as a dependency, and we don't want that to happen when we have installed ImageMagick from source. :)
 
Status
Not open for further replies.
Back
Top