How to Install Imagick on Ubuntu by OpenLiteSpeed web server?

Make sure you have Imagick package installed already on ubuntu. If you dont you can install it with:

apt install libmagickwand-dev imagemagick

Then you will need to compile the extension of LSPHP73. You can follow these commands here:

apt install lsphp73-dev
cd /tmp/
wget https://pecl.php.net/get/imagick-3.4.4.tgz
tar -xf imagick-3.4.4.tgz
cd imagick-3.4.4
/usr/local/lsws/lsphp73/bin/phpize7.3
./configure --with-php-config=/usr/local/lsws/lsphp73/bin/php-config7.3
make
make install
echo 'extension=imagick.so' >> /usr/local/lsws/lsphp73/etc/php/7.3/mods-available/imagick.ini
/usr/local/lsws/bin/lswsctrl restart

This will install the lsphp73-dev package, download the PHP PECL extension, extract it, build it for that specific version of PHP, and set it up to work. You can replace 7.3 and 73 with a different version as well.


Just do the following:

sudo apt-get update
sudo apt-get install lsphp73-imagick -y

Note: this was tested on an Ubuntu 18.04 WordPress VM by OpenLiteSpeed running on Google Cloud Compute Platform.