
This article provides a guide for how to fix PHP Warning: Module ‘imagick’ already loaded errors.
🛠️ How to Fix PHP Warning: Module ‘imagick’ already loaded Error
When PHP encounters this warning, it means that the Imagick extension is being loaded more than once in your configuration files. While the warning itself usually won’t break functionality, it clutters logs and may indicate configuration mismanagement.
This guide will walk you through diagnosing and fixing the issue on Linux servers (Ubuntu, Debian, CentOS/AlmaLinux/Rocky), cPanel/WHM environments, and even local setups.
-
✅ Understand the Error
PHP loads extensions from:
php.ini(the main PHP configuration file),- additional
conf.d/*.inifiles, or - custom per-domain PHP configs (such as in cPanel or PHP-FPM pools).
If Imagick is referenced in more than one place, PHP complains that it’s “already loaded”.
-
🔍 Locate Duplicate References
Run the following command to find all instances where
imagickis enabled:grep -r "imagick" /etc/php* 2>/dev/null
This will search across all PHP versions/config directories. Common locations include:
/etc/php/8.1/cli/php.ini/etc/php/8.1/apache2/php.ini/etc/php/8.1/fpm/php.ini/etc/php/8.1/mods-available/imagick.ini/etc/php/8.1/conf.d/20-imagick.ini
In cPanel/WHM servers, check:
/opt/cpanel/ea-php*/root/etc/php.d/imagick.inigrep -ir imagick /opt/cpanel/ea-php*/root/etc
-
🧹 Remove Duplicate Load Directives
In whichever files you find, look for:
extension=imagick.so
or
zend_extension=imagick.so
Make sure only one instance remains active.
For example:- If
php.inihasextension=imagick.so, and20-imagick.inialso has it, remove it fromphp.ini. - Always prefer keeping it inside
conf.d/20-imagick.ini(this is the standard practice).
- If
-
♻️ Restart PHP Services
After cleaning up duplicates, restart PHP services:
- For Apache + mod_php:
sudo systemctl restart apache2
or
sudo systemctl restart httpd
- For PHP-FPM:
sudo systemctl restart php8.1-fpm
- For cPanel/WHM servers:
/scripts/restartsrv_httpd
-
🧪 Verify Fix
Check PHP configuration:
php -m | grep imagick
Expected output:
imagick
(only once).
Check logs again:
tail -f /var/log/apache2/error.log # or tail -f /usr/local/cpanel/logs/error_log
You should no longer see the warning.
-
⚠️ Special Cases
a) cPanel/WHM
- WHM’s EasyApache may auto-generate
imagick.ini. If you’ve manually addedextension=imagick.soinphp.ini, remove it. - Only use EasyApache to manage PHP extensions.
b) Plesk
- Plesk adds extensions via
conf.d. Remove manual entries from globalphp.ini.
c) Custom Compiled PHP
- If you compiled Imagick manually, ensure that your
.inientry is inconf.d/and not hardcoded multiple times.
- WHM’s EasyApache may auto-generate
-
🧾 Summary
- The error happens when Imagick is loaded twice.
- Fix by removing duplicate
extension=imagick.solines. - Keep the extension declaration only in the appropriate
.inifile (conf.d/20-imagick.ini). - Restart PHP services and confirm with
php -m.
✅ After this, your PHP environment should be clean, without duplicate load warnings.
Bonus: Resolve Every PHP Module Extension Load Errors with 1 Command
If you’re simply looking to mass correct these PHP extension loading conflicts across entire servers, then you’ll appreciate this next part!
We’ve developed a universal cleanup script that works not only for imagick, but for any PHP extension that’s accidentally being loaded multiple times.
- Single script to identify, resolve, and log all actions
- Detects duplicates for all extensions.
- Removes extra
extension=orzend_extension=lines (keeps the officialconf.d/*file). - Creates backups of every changed file.
- Logs everything to
/var/log/php_extension_cleanup.log. - Detects cPanel, Debian/Ubuntu, or RHEL/Alma/Rocky and restarts the proper services.
🔧 Install & Run
- Run this single command to solve all module loading issues for all PHP versions and all extensions:
sudo wget https://phpcleanup.radnoc.com -O php-extension-cleanup.sh && bash php-extension-cleanup.sh
✅ Benefits
- Works for all PHP versions(any PHP5, PHP7, PHP8)
- Works for all PHP extensions (
imagick,redis,xdebug, etc). - Automatically avoids touching the proper
conf.dloader files. - Keeps backups for rollback.
- Auto restarts services depending on whether it’s cPanel, Debian/Ubuntu, or RHEL/Alma/Rocky.
Alternatively, use Dry-run to not make any of the changes but log everything:
🔍 Dry-run (preview changes only):
sudo wget https://phpcleanup.radnoc.com -O php-extension-cleanup.sh && bash php-extension-cleanup.sh --dry
📜 View Logs
less /var/log/php_extension_cleanup.log
✅ Benefits
- Shows which files contain duplicate extension lines.
- Displays exactly which lines would be removed.
- No changes are made.
✅ With this, you can test safely first with --dry, then re-run without it to fix.
Conclusion
You now know how to fix “PHP Warning: Module ‘imagick’ already loaded” errors.
✅ Easy Website Management with cPanel Support
Running a business is hard enough — managing your website shouldn’t be. That’s why we include full cPanel support with every hosting plan:
- ✅ Simple Dashboard – No tech skills needed. Easily manage your website, emails, and more from one place.
- ✅ Quick App Installs – Launch WordPress, shopping carts, or other tools with just one click.
- ✅ Professional Email – Create business email addresses (like you@yourbusiness.com) in minutes.
- ✅ Reliable Backups – Keep your website safe with easy-to-use backup and restore options.
- ✅ Secure & Protected – Manage your site’s security and SSL certificates with built-in tools.
- ✅ Real Help, Anytime – Our expert support team is available 24/7 for anything you need.
💬 What Our Customers Say
“I have had nothing but good experiences with Rad Web Hosting. The staff is there to help you to make sure that you stay online and I haven't had any downtime with my server in the time I have been with Rad Web Hosting and I have had my server for over two years.”
— Janice L., Owner of RJGM
🏆 Trusted by Small Business Owners Nationwide
🚀 Get Started Today
Take the stress out of website management. With cPanel support and expert help just a click away, you can focus on what matters most — growing your business.
Choose Your Plan Now








