How To Enable Imagemagick Extension for PHP on Arch Linux

I recently migrated some of my WordPress sites to an Arch Linux server. I installed Nginx, MariaDB and PHP7 on Arch Linux. Then the thumb image of WordPress post does not work any more. I looked at the WordPress /upload/ folder on my server and found that no other image sizes were generated when I upload an image. Also when I try to edit images in the WordPress image editor, It tells me

Image rotation is not supported by your web host

In order to crop and rotate images in WordPress, you have to enable the Imagemagick extension for PHP. Here’s how to do it on Arch Linux server.

Update: You can now easily enable this imagemaick PHP extension by running the following commands on your Arch Linux server.

sudo pacman -S imagemagick php-imagick

You don’t need to read the following instructions anymore.

Install Yaourt

We will use pecl which is included in the php-pear AUR package to compile Imagemagick extension . So first we need to install Yaourt so that we can install AUR packages.

Open repository configuration file with root privilege.

sudo nano /etc/pacman.conf

Append the following lines at the end of this file. This will add the yaourt repo from repo.archlinux.fr.

[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch

Save and close this file. Now update repository info and install Yaourt package manager plus a very import tool called fakeroot. This is for Yaourt to build Arch Linux package.

sudo pacman -Sy yaourt fakeroot

fakeroot has the ability to simulate superuser privileges in the build process so you don’t have to prefix yaourt command with sudo.

Install php-pear

sudo pacman -S binutils

yaourt php-pear

Compile and Install Imagemagick Extension with pecl

Install build tools

sudo pacman -S autoconf make gcc pkg-config imagemagick re2c

You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. Now compile and install Imagemagick extension

sudo pecl install imagick

After imagick is installed, open php.ini configuration file.

sudo nano /etc/php/php.ini

Add the following line to enable imagick extension.

extension=imagick.so

Save and close the file. Then reload php-fpm.

sudo systemctl reload php-fpm

Now you should be able to crop and rotate images in WordPress.

Rate this tutorial
[Total: 2 Average: 4.5]

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here