How to install ImageMagick library and php extension on Ubuntu?
I was working on a symfony2 project in which I have to place watermark on images. I used ImageMagicK extension, it’s called as Imagick in PHP. I had found some difficulties while installation and then successfully installed. So I am sharing that procedure here.
- Get the package from pecl site for Imagick package. Following is the URL https://pecl.php.net/package/imagick
- Download it by wget command. I used following package.
wget http://pecl.php.net/get/imagick-3.4.4RC2.tgz
3. Unzip the downloaded file by following command.
tar xvf imagick-3.4.4RC2.tgz
4. Then go to the extracted folder.
cd imagick-3.4.4RC2.tgz
Then following commands. Phpize command is used to prepare a build environment for PHP extension.
phpize
./configure
make
make install
After running last command extension will be installed and added to php.ini file. If its not added then you will need to add it in php.ini file.
extension=imagick.so
Then at the end just restart apache.
sudo service apache2 restart
To check if imagick installed successfully, you can run following command. This will show list of modules that are installed. After installation imaick should be listed there.
php -m