✅ (solved) how to fix php warning: module 'imagick' already loaded
Learn how to fixphp warning: module ‘imagick’ already loaded error!

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.

  1. ✅ Understand the Error

    PHP loads extensions from:

    • php.ini (the main PHP configuration file),
    • additional conf.d/*.ini files, 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”.

  2. 🔍 Locate Duplicate References

    Run the following command to find all instances where imagick is 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.ini
      grep -ir imagick /opt/cpanel/ea-php*/root/etc
  3. 🧹 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.ini has extension=imagick.so, and 20-imagick.ini also has it, remove it from php.ini.
    • Always prefer keeping it inside conf.d/20-imagick.ini (this is the standard practice).
  4. ♻️ 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
    
  5. 🧪 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.

  6. ⚠️ Special Cases

    a) cPanel/WHM

    • WHM’s EasyApache may auto-generate imagick.ini. If you’ve manually added extension=imagick.so in php.ini, remove it.
    • Only use EasyApache to manage PHP extensions.

    b) Plesk

    • Plesk adds extensions via conf.d. Remove manual entries from global php.ini.

    c) Custom Compiled PHP

    • If you compiled Imagick manually, ensure that your .ini entry is in conf.d/ and not hardcoded multiple times.
  7. 🧾 Summary

    • The error happens when Imagick is loaded twice.
    • Fix by removing duplicate extension=imagick.so lines.
    • Keep the extension declaration only in the appropriate .ini file (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= or zend_extension= lines (keeps the official conf.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

  1. 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.d loader 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, AnytimeOur 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

Trust badges: 99. 9% uptime | 24/7 support | secure hosting | money-back guarantee

🚀 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
Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX.
lg