Errors such as Call to undefined function imagecreatefromjpeg() or Class "IntlDateFormatter" not found mean a PHP extension is missing. On a VPS you install extensions yourself, and the main trap is installing them for the wrong PHP version. This guide covers Ubuntu/Debian and AlmaLinux/Rocky.
Before you start
- Root or sudo access.
- Know which PHP version your site uses. The CLI and the web server can differ: compare
php -vwith aphpinfo()page or your PHP-FPM service name.
See which extensions are loaded
php -mFor a specific version on servers with several: php8.3 -m. Check one extension:
php -m | grep -i intlThe web server's PHP may load different files than the CLI; phpinfo() shows the truth for websites (delete the file afterwards).
Install on Ubuntu and Debian
Packages are named php<version>-<extension>:
apt install php8.3-intl php8.3-gd php8.3-mbstring php8.3-zip php8.3-curl php8.3-xml php8.3-bcmathPopular PECL extensions are packaged too: php8.3-redis, php8.3-imagick, php8.3-apcu. Search with apt search php8.3- | less. Newer PHP versions come from the ondrej/php PPA (Ubuntu) or packages.sury.org (Debian).
Extensions are enabled automatically. Toggle them with:
phpenmod -v 8.3 intlphpdismod -v 8.3 xdebugInstall on AlmaLinux and Rocky
With the default AppStream PHP:
dnf install php-intl php-gd php-mbstring php-zip php-xml php-bcmath php-pecl-zipWith Remi's repository and versioned collections:
dnf install php83-php-intl php83-php-pecl-redis5Remi builds have their own config folder (/etc/opt/remi/php83/php.d/) and service (php83-php-fpm).
Build an extension with PECL
Only if no package exists:
apt install php8.3-dev php-pear build-essentialpecl -d php_suffix=8.3 install mongodbThen enable it by creating an ini file, e.g. /etc/php/8.3/mods-available/mongodb.ini with extension=mongodb.so, and run phpenmod -v 8.3 mongodb. PECL builds must be rebuilt after major PHP upgrades.
Restart PHP and verify
systemctl restart php8.3-fpmUse php-fpm on AlmaLinux, or restart Apache if PHP runs as an Apache module. Verify:
php8.3 -m | grep -iE 'intl|gd|redis'Then reload your site or phpinfo() page and search for the extension.
Common extensions and what needs them
| Extension | Typically needed by |
|---|---|
mysqli / pdo_mysql | WordPress, Laravel, any MySQL app |
gd or imagick | Image resizing and thumbnails |
intl | Laravel, Magento, WooCommerce, localisation |
mbstring | Multibyte text, most frameworks |
zip | Plugin and theme installs, Composer |
curl | API calls, updates |
opcache | Performance; enable everywhere |
redis / apcu | Object caching |
Troubleshooting
- Extension shows in CLI but not on the website: you installed it for a different version than PHP-FPM uses, or did not restart FPM.
- PHP Warning: Module already loaded: the extension is enabled twice; remove the duplicate ini file.
- Unable to load dynamic library: the .so was built for another PHP version. Reinstall the package for the correct version.
PHP extensions FAQ
How do I enable extensions on cPanel hosting?
Use cPanel → Software → Select PHP Version (CloudLinux PHP Selector) and tick the extensions; no root access needed.
Should I enable Xdebug in production?
No. It slows PHP considerably; use it only on development servers.
Do extensions survive a PHP upgrade?
Packaged extensions must be installed again for the new version (e.g. php8.4-intl).
