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.
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
[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.
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.
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.