How to Install PHP-IMAGICK on Debian (13, 12, 11)

Last updated Thursday, March 12, 2026 9:27 am 8 min read

Image uploads, thumbnail generation, and PDF previews break quickly when the Imagick extension is missing from a PHP stack. You can install PHP-Imagick on Debian from the default APT sources or from the Sury PHP repository, which gives Debian 13, 12, and 11 a clean path to the ImageMagick-backed PHP module.

The default package is the right fit when you stay on Debian’s PHP branch. That applies to minimal and server installs too, because APT pulls the matching CLI packages when they are missing. Use Sury only when you already run, or need, a specific PHP version outside Debian’s default track. If you need the standalone command-line tools instead of the PHP extension, install ImageMagick on Debian.

Install PHP-Imagick on Debian

Start with Debian’s package when the server follows the distro PHP branch. Move to the Sury method only when you need a versioned package such as php8.4-imagick for an alternate PHP stack.

Install PHP-Imagick from Debian’s Default APT Sources

Debian’s package is the shortest path when you want the distro-supported PHP branch and standard security updates.

sudo apt update && sudo apt upgrade

The commands below use sudo for tasks that need root privileges. If your account does not have sudo access yet, follow the guide to add a user to sudoers on Debian.

Install the extension with Debian’s generic package name. On Debian 13 and 12, php-imagick pulls the matching branch package, while Debian 11 ships the extension directly under the same package name.

sudo apt install php-imagick

On Debian 13, APT resolves the extension like this:

The following NEW packages will be installed:
  php-common php-imagick php8.4-cli php8.4-common php8.4-imagick
  php8.4-opcache php8.4-phpdbg php8.4-readline
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.

Bookworm installs the matching php8.2-* packages, and Bullseye pulls the PHP 7.4 CLI stack on a clean system.

Confirm that the CLI SAPI loads the extension:

php -m | grep -x imagick
imagick

If the command returns imagick, the extension is active for PHP CLI. Web servers that use PHP-FPM or Apache still need a service restart, which is covered in the troubleshooting section.

Install Version-Specific PHP-Imagick Packages from the Sury Repository

Use Sury when the server already runs a specific PHP branch, or when Debian’s default branch is not the version you need.

sudo apt install ca-certificates curl

Install the Sury keyring package first:

curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb

Next, detect your Debian codename in the same terminal session. This keeps the repository file correct for Trixie, Bookworm, or Bullseye without making you type the codename by hand.

CODENAME=$(. /etc/os-release && echo "$VERSION_CODENAME")
echo "$CODENAME"
trixie

Use that variable to write the DEB822 source file:

printf '%s\n' \
"Types: deb" \
"URIs: https://packages.sury.org/php/" \
"Suites: ${CODENAME}" \
"Components: main" \
"Signed-By: /usr/share/keyrings/debsuryorg-archive-keyring.gpg" | sudo tee /etc/apt/sources.list.d/sury-php.sources > /dev/null

Check the file before you refresh APT:

cat /etc/apt/sources.list.d/sury-php.sources
Types: deb
URIs: https://packages.sury.org/php/
Suites: trixie
Components: main
Signed-By: /usr/share/keyrings/debsuryorg-archive-keyring.gpg

The printf | sudo tee form writes the .sources file as root, because a plain > redirection would still run as your regular user. VERSION_CODENAME comes from /etc/os-release, which is present on Debian 13, 12, and 11, so this method does not depend on lsb_release. If you open a new terminal before the printf command, run the CODENAME=... line again first. The Suites: line will show trixie, bookworm, or bullseye depending on your release.

Refresh APT and confirm that the repository is active:

sudo apt update
apt-cache policy php8.4-imagick
Get:1 https://packages.sury.org/php [your-release] InRelease
Get:2 https://packages.sury.org/php [your-release]/main amd64 Packages

php8.4-imagick:
  Installed: (none)
  Candidate: 3.x.x
  Version table:
     3.x.x 500
        500 https://packages.sury.org/php [your-release]/main amd64 Packages

Your codename will be trixie, bookworm, or bullseye. The version number changes over time, but the important part is the packages.sury.org/php source line in the output.

Make sure the matching PHP runtime is already installed before you add the extension package. For example, php8.4-imagick needs one PHP 8.4 SAPI such as php8.4-cli, php8.4-fpm, or libapache2-mod-php8.4. If the server still needs the rest of the PHP stack, install PHP on Debian first.

sudo apt install php8.4-imagick

Replace 8.4 with the branch that matches your installed PHP version, such as 8.3, 8.2, or an older branch like 8.1 if your Sury stack still uses it. When you are not sure which package name exists for your branch, check it first with apt-cache policy php8.1-imagick and swap in the version you actually need.

If the same PHP branch has CLI installed, confirm that the extension is loaded:

php -m | grep -x imagick
imagick

If that command returns nothing, the extension package does not match the active PHP branch, or the web SAPI still needs a restart.

Compare PHP-Imagick Installation Methods on Debian

Both methods install the same extension, but they target different PHP maintenance models.

MethodChannelPHP VersionsUpdatesBest For
Debian default APT sourcesDebian PackagesPHP 8.4 on Debian 13, PHP 8.2 on Debian 12, PHP 7.4 on Debian 11Standard apt upgradesMost servers that stay on Debian’s default PHP branch
Sury PHP repositorySury PHP RepositoryVersion-specific packages such as PHP 8.2, 8.3, or 8.4Standard apt upgrades after the repo is addedHosts that already run a specific Sury PHP branch

Debian 13 and 12 map php-imagick to the distro’s default branch package. Debian 11 keeps the extension under php-imagick, but a clean install still pulls the Bullseye PHP 7.4 CLI stack.

Troubleshoot PHP-Imagick on Debian

Most problems come from a service that has not been restarted yet, or from a mismatch between the active PHP branch and the installed Imagick package.

Restart PHP-FPM After Installing PHP-Imagick on Debian

If CLI checks succeed but the web application still cannot load Imagick, restart the PHP-FPM service that matches your active PHP branch.

systemctl list-units --type=service 'php*-fpm.service'
sudo systemctl restart php8.4-fpm
systemctl is-active php8.4-fpm
php8.4-fpm.service loaded active running The PHP 8.4 FastCGI Process Manager
active

If Apache uses libapache2-mod-php instead of PHP-FPM, restart Apache with sudo systemctl restart apache2. For a full web stack setup, you can install Nginx on Debian or install Apache on Debian.

Fix the Class Imagick Not Found Error on Debian

Check the active PHP branch and the installed Imagick package names together, because the error usually means those two do not match.

php -v | head -n 1
dpkg -l 'php*-imagick' | grep '^ii'
PHP 8.4.x (cli)
ii  php8.4-imagick  3.x.x  amd64  Provides a wrapper to the ImageMagick library

If PHP reports 8.4 but the installed extension package is php8.2-imagick, remove the wrong branch and install the matching one. Restart PHP-FPM or Apache afterward so the web SAPI picks up the change.

Inspect PHP-Imagick Configuration on Debian

Use PHP’s module information view when you need to confirm the extension version and the ImageMagick library it is linked against.

php --ri imagick | sed -n '1,8p'
imagick

imagick module => enabled
imagick module version => 3.x.x
Imagick compiled with ImageMagick version => ImageMagick 6.x or 7.x
Imagick using ImageMagick library version => ImageMagick 6.x or 7.x

This view is useful when the package is installed but the application still behaves as if the extension is missing.

Update or Remove PHP-Imagick on Debian

APT updates and removes the extension cleanly, but review any autoremove prompt before you confirm it on a host that already runs other PHP workloads.

Update PHP-Imagick on Debian

Use the package name that matches the source you installed from.

sudo apt update && sudo apt install --only-upgrade php-imagick

sudo apt update && sudo apt install --only-upgrade php8.4-imagick

The first command updates Debian’s default package. The second updates the version-specific Sury package, so replace 8.4 with the branch you actually use.

Remove PHP-Imagick on Debian

Remove the extension package, then let APT clean up dependencies that are no longer needed.

sudo apt remove php-imagick
sudo apt autoremove

sudo apt remove php8.4-imagick

On a clean Debian 13 install, apt autoremove also removed php8.4-cli, php8.4-common, and related helpers because the extension install had pulled them in automatically. Review the removal list carefully before you confirm it on a production host.

Confirm that Debian’s generic package is no longer installed:

apt-cache policy php-imagick
php-imagick:
  Installed: (none)
  Candidate: 3.x.x
  Version table:
     3.x.x 500
        500 http://deb.debian.org/debian [your-release]/main amd64 Packages

Remove the Sury PHP Repository from Debian

Delete the DEB822 source file, remove the keyring package, and refresh APT if you no longer want Sury packages on the server.

sudo rm /etc/apt/sources.list.d/sury-php.sources
sudo apt remove debsuryorg-archive-keyring
sudo apt update

Check that APT no longer has the Sury source configured:

grep -R "packages.sury.org/php" /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null
No output

PHP-Imagick on Debian FAQ

Do I need the Sury repository to install PHP-Imagick on Debian?

No. Debian 13, 12, and 11 already provide php-imagick in the default APT sources. Use the Sury repository only when you need a different PHP branch than the one Debian ships by default.

Is php-imagick the same as ImageMagick on Debian?

No. php-imagick is the PHP extension that talks to the ImageMagick libraries, while ImageMagick itself provides the standalone command-line tools such as magick, convert, and related utilities.

Should I install php-imagick or php8.4-imagick on Debian?

Use php-imagick when you install from Debian’s default APT sources. Use a version-specific package such as php8.4-imagick when the server uses the Sury PHP repository and the extension must match that exact PHP branch.

Why does PHP still report Class Imagick not found?

The installed extension package usually does not match the active PHP branch, or PHP-FPM or Apache has not been restarted yet. Compare php -v with dpkg -l 'php*-imagick', install the matching package, and restart the PHP service that serves your application.

Conclusion

PHP-Imagick is installed on Debian and ready for thumbnail creation, format conversion, and other image-processing work inside your PHP stack. If the server still needs the rest of the runtime, install PHP on Debian, then pair it with install Nginx on Debian or install Apache on Debian.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: