Upload issues with imagick and WordPress

MrIver

Active Member
PartnerNOC
Feb 24, 2020
39
7
8
Denmark
cPanel Access Level
Root Administrator
Hi guys,

We just installed imagick on all our servers beacause WordPress displays and "error" under "Site health", that says that imagick should be installed. Many of our clients have noticted this, and thus we have installed it.

However, imagick is not working well with LiteSpeed webserver, and our customers are now getting image upload-errors like described here:


We talked to LiteSpeed and they said that is was a imagick bug, and reffered us to their solutions:


However, getting our customers to edit their fuctions.php file is not a great solution.

So my questions is, if anyone in here have found a host-side fix besides just not using imagick?

Thanks!
 

LucasRolff

Well-Known Member
Community Guide Contributor
May 27, 2013
143
88
78
cPanel Access Level
Root Administrator
LiteSpeed has a setting in the WebConsole to limit the amount of allocated memory PHP can consume, there's a soft and a hard memory limit defined on the web server level ( I believe the default is about 2 gigabyte ), Apache doesn't have such feature, thus it does not appear as an issue in Apache environment (unless you're short on memory).

Imagick is known (sadly) for being one big memory leak, I've managed to make a 300 kilobyte PNG image consume more than 4 gigabytes consumed (and more than 10 gigabytes allocated), simply by using the Media Library in WordPress.

Since LiteSpeed does protect against this, that can cause broken uploads, and thus generating huge temp files (and sometimes Imagick just crashes slightly internally without actually cleaning out the temp files, even if it's successful at the upload).

My advise is to simply keep Imagick disabled and use the GD Library as the "standard", and those who needs PDF previews generated can get the module explicitly enabled, you can do this per user by using:

Code:
<IfModule Litespeed>
LS_EXTAPP_ENV PHP_INI_SCAN_DIR=/opt/cpanel/ea-php73/root/etc/php.d:/home/$user/
</IfModule>
In the Apache user includes (remember both for SSL and STD directories).

Alternatively, there's a WP plugin to use the imagick binary in WordPress and not relying on the actual PHP Module - it still suffers from the leaks, despite they're less frequent.

And ideally check if there's an existing case for WP to not actually list Imagick as being a strict requirement, because it's silly :)
 
  • Like
Reactions: cPanelLauren

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
I'd like to see if our analysts can look over this further for you. Can you please open a ticket using the link in my signature? Once open please reply with the Ticket ID here so that we can update this thread with the resolution once the ticket is resolved.


Thanks!
 

MrIver

Active Member
PartnerNOC
Feb 24, 2020
39
7
8
Denmark
cPanel Access Level
Root Administrator
Hi Lucas,

Thank you very much for your great reply.

We have also come to the conclusion, that we need to deactivate imagick and rely on GD instead. Even though WordPress recommends the module under "site health", it simply produces way more errors/issues than it resolves, and thus is not worth the trouble - not for us as a host, not for our clients.

We will keep it deactivated untill imagick gets the bug fixed.

Thanks again for your time!
 
  • Like
Reactions: cPanelLauren