This article only explains how to install a custom version of ImageMagick using a custom version of PHP. It does not explain how to use ImageMagick itself.
Visit the following article for instructions on using DreamHost's pre-installed ImageMagick with MediaWiki:
ImageMagick is a free software suite used to convert and edit images and is installed by default on all DreamHost servers. To view the current version, log in to your server via SSH and then run the following command:
[server]$ dpkg -l | grep magick
For further details on ImageMagick, visit the following site:
Preparing the environment
Installing a custom version of ImageMagick is only possible if you're using a custom version of PHP. This means you must first install a custom version under your SHELL user. Once installed, proceed with the following sections.
- Log into your server via SSH.
- Install a custom version of PHP under your SHELL user.
Make sure you've completely followed the steps to install a custom version of PHP. Your SHELL environment must be running this new version before you can proceed.
- Make sure you're in your user's main directory, and not your domain's directory.
- Create a build directory where all the required tools are downloaded, configured, and then compiled:
[server]$ mkdir build
- Create a local directory where all the required tools are deployed:
[server]$ mkdir local
Once you have created the /build and /local directories, proceed with the following commands. This example uses version 7.0.7-28.
[server]$ cd build [server]$ wget "http://www.imagemagick.org/download/ImageMagick.tar.gz" [server]$ tar zxvf ImageMagick.tar.gz [server]$ cd ImageMagick-7.0.7-28 [server]$ ./configure --prefix=$HOME/local --enable-shared --enable-symbol-prefix [server]$ make [server]$ make install
If everything runs smoothly, up-to-date ImageMagick binaries, libs collection, documentation, and so on are available in your local directory (and sub-directory).
Start using this local directory by running the following command:
[server]$ export PATH=$HOME/local/bin:$PATH
Finally, check the version:
[server]$ convert --version Version: ImageMagick 7.0.7-28 Q16 x86_64 2018-04-29 http://www.imagemagick.org
Building the Imagick PHP module
- Navigate to your build directory:
[server]$ cd $HOME/build
- Visit http://pecl.php.net/package/imagick and choose the version you wish to use.
- Run the following commands based on the version you're using. This example uses 3.4.3:
[server]$ wget https://pecl.php.net/get/imagick [server]$ tar zxvf imagick [server]$ cd imagick-3.4.3
- Run the following to ensure that imagick compiles smoothly. Make sure to change 'username' to your actual SHELL username:
[server]$ /home/username/local/bin/phpize [server]$ export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig [server]$ ln -s $HOME/local/include/ImageMagick-7 $HOME/local/include/ImageMagick [server]$ ./configure --prefix=$HOME/local --with-imagick=$HOME/local [server]$ make
You may see a few compilation warnings, which you can safely ignore. Look for the following which ensures a successful installation:
Libraries have been installed in: /home/username/build/imagick-3.4.3/modules
- To finish, run make install to copy the module to your custom extensions directory:
[server]$ make install Installing shared extensions: /home/username/local/lib/php/extensions/no-debug-non-zts-20170718/ Installing header files: /home/username/local/include/php/
Configuring PHP to use this extension
Since you installed a custom version of PHP 7.2.5, there is no php.ini file. Create it in the /local/lib directory. For example:
[server]$ touch $HOME/local/lib/php.ini
This creates the file. Then, kill off any running PHP processes to ensure PHP is aware of this new config file:
[server]$ killall -9 php-cgi
You can see it's now being used by creating a phpinfo.php file:
Visit your site to view the file. In the first block, 'Loaded Configuration File' points to the file you just created. On that page, search for extension_dir which points to the following:
Finally, run the following command. This adds a line to your php.ini file that points to the imagick.so module within the extensions directory:
[server]$ echo "extension = $HOME/local/lib/php/extensions/no-debug-non-zts-20170718/imagick.so" >> $HOME/local/lib/php.ini
Visit your phpinfo.php file again where the 'imagick' block exists with your new version.