Most PHP applications, from WordPress to Laravel, need a handful of PHP extensions such as mbstring, intl, xml and pdo_mysql. On your own VPS you install them with the operating system's package manager. This guide covers the current Linux systems, what changed since CentOS reached end of life, and what to do if you are on shared hosting instead.
Check what is loaded with php -m. On Ubuntu or Debian, install missing extensions with sudo apt install php-intl php-mbstring …; on AlmaLinux or Rocky Linux, use sudo dnf install php-intl php-mbstring …. Then restart PHP-FPM or the web server, and confirm with a test page, because the command line and the website can load different settings. CentOS Linux is end of life, so don't build new servers on it. On shared hosting you can't install extensions: ask support.
1. CentOS, cPanel and what changed
This article used to be written for CentOS with cPanel. Two things have changed:
- CentOS Linux has reached end of life and gets no more security updates. For a new server, choose a maintained distribution. AlmaLinux and Rocky Linux are the usual replacements if you want a CentOS-like system; Ubuntu LTS and Debian are the other common choices.
- Domain India VPS plans don't offer cPanel, because of its licence cost. You choose a Linux OS, and optionally one of the control panels listed on the VPS page, or run the server with no panel. If you need cPanel, our shared cPanel hosting includes it.
The commands below work on a plain VPS with no control panel. If you run your own licensed cPanel & WHM server elsewhere, see section 7.
2. The essential extensions
These are the extensions most frameworks and CMSs ask for. Several are built into PHP and are always present.
| Extension | What it does | Usually |
|---|---|---|
| openssl | Encryption and TLS connections | Built in |
| json | JSON encoding and decoding | Built in since PHP 8.0 |
| ctype | Character checks, such as "digits only" | Built in on most builds |
| tokenizer | Parses PHP code, used by frameworks | Built in on most builds |
| pdo_mysql | Database access through PDO | Package |
| mysqli | MySQL access, used by WordPress | Package |
| mbstring | Handles UTF-8 and non-Latin text | Package |
| xml, dom | Reads and writes XML | Package |
| intl | Locale-aware numbers, dates and sorting | Package |
| curl | HTTP requests to APIs | Package |
| gd or imagick | Image resizing and thumbnails | Package |
| zip | ZIP archives, used by updates and imports | Package |
| fileinfo | Detects file types for safe uploads | Built in on most builds |
| exif | Reads photo metadata | Package or built in |
| bcmath | Exact decimal maths | Package |
For what each extension does in more detail, see a list of PHP modules and their functions.
3. Check what is already loaded
Log in to your VPS over SSH and run:
php -v
php -m
php -m | grep -i -E 'intl|mbstring|pdo_mysql'php -m shows the command-line PHP. Your website may run a different PHP version, or PHP-FPM with its own settings, so also check what the web server sees. Create a test file in your site's folder:
<?php
foreach (['intl', 'mbstring', 'pdo_mysql', 'gd', 'zip'] as $ext) {
echo $ext . ': ' . (extension_loaded($ext) ? 'loaded' : 'missing') . "\n";
}Open it in your browser, read the result, then delete the file. On your own server you can also use a phpinfo() page, but delete it straight away: it shows your whole configuration to anyone who finds it.
4. Install extensions on Ubuntu or Debian
Package names start with php-, such as php-intl, which installs the extension for the distribution's default PHP version. If you run a specific version, include it, as in php8.3-intl.
- Refresh the package list.Run
sudo apt update. - Install what you need.For a typical Laravel or WordPress site:
sudo apt install php-mysql php-mbstring php-xml php-intl php-curl php-zip php-gd php-bcmath. Thephp-mysqlpackage provides bothmysqliandpdo_mysql. - Check the extension is switched on.Debian-based systems enable new extensions automatically. You can switch one on or off with
sudo phpenmod intlorsudo phpdismod intl. - Restart PHP.Run
sudo systemctl restart php8.3-fpm, using your version number, orsudo systemctl restart apache2if PHP runs as an Apache module. - Confirmwith
php -mand the test file from section 3.
5. Install extensions on AlmaLinux or Rocky Linux
These systems use dnf, the successor to yum. The PHP version comes from the distribution; on some releases you can pick a newer one as a module stream, which you can list with sudo dnf module list php.
- Find the package. Run `dnf search php-grep -i intl` to see the exact name on your release.
- Install what you need.For example:
sudo dnf install php-mysqlnd php-mbstring php-xml php-intl php-gd php-bcmath php-opcache. Herephp-mysqlndprovidesmysqliandpdo_mysql. - Restart PHP.Run
sudo systemctl restart php-fpm, and restart the web server (httpdornginx) if you changed its configuration. - Confirmwith
php -mand the test file.
Some extensions, such as zip, redis or imagick, may not be in the base repositories. The EPEL repository, or a PHP repository your distribution's community recommends, usually has them. Prefer packages to compiling.
6. Extensions from PECL
When no package exists, PECL builds the extension from source:
sudo pecl install redisYou then need to load it: create a file such as /etc/php/8.3/mods-available/redis.ini on Ubuntu and Debian (then sudo phpenmod redis), or /etc/php.d/40-redis.ini on AlmaLinux and Rocky Linux, containing extension=redis. Restart PHP-FPM afterwards. PECL needs build tools and the PHP development headers (php-dev or php-devel) installed first, and a PECL build must be redone after a PHP version upgrade, which is one more reason to prefer packages.
Old guides still list mcrypt, xmlrpc and suhosin. mcrypt and xmlrpc are no longer part of PHP and suhosin is not maintained for PHP 8. If an application still asks for them, it needs updating, not an old extension. Likewise yum is replaced by dnf, and CentOS paths such as /etc/httpd/logs/error_log may not exist on your system.
7. If your server runs cPanel & WHM
On a server where you hold your own cPanel licence, PHP comes from EasyApache 4, and extensions are managed there rather than with plain dnf or apt package names:
- In WHM, open Software › EasyApache 4, click Customize on the current profile, open PHP Extensions, switch on the extensions you need for each PHP version, then Review and Provision.
- EasyApache package names include the PHP version, for example
ea-php83-php-intl. - Provisioning applies the change. If a site still doesn't see the extension, restart PHP-FPM as well as Apache, and check with the test file from section 3.
cPanel's own documentation is the reference for the EasyApache screens on your version.
8. On Domain India shared hosting
On shared hosting the PHP builds are shared by every account on the server, so you can't install, compile or load an extension yourself, and a php.ini or .user.ini line can't add one. The common extensions are already loaded on our cPanel and DirectAdmin servers. What you can do:
- Check what your site sees with the test file from section 3.
phpinfo()is disabled on our cPanel servers, so useextension_loaded(). - Try another PHP version in your panel; see how to change the PHP version.
- Ask support. Open a ticket with the extension name, your domain and your PHP version, and we will tell you whether it can be provided.
Some functions are switched off for security on shared hosting even when their extension is loaded. See PHP disabled functions on shared hosting.
9. Where Domain India fits
If you need extensions shared hosting doesn't provide, your own PHP version or PECL modules, a VPS gives you root access to install them. Domain India VPS plans are self-managed by default: you choose the OS and look after the software and updates yourself.
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
- 50 GB NVMe SSD Storage
- 100 GB Monthly Bandwidth
- 5 Websites
- 50 Email Accounts
Card prices are live list prices, excluding 18% GST.
How do I check which PHP extensions are installed?
Run php -m over SSH to list the extensions loaded by command-line PHP. Because the website can use a different PHP version or configuration, also upload a small file that prints extension_loaded('name') for each extension you need, open it in a browser and then delete it.
How do I install a PHP extension on Ubuntu?
Run sudo apt update, then sudo apt install php-intl (or the extension you need, such as php-mbstring or php-mysql). Restart PHP-FPM with sudo systemctl restart php8.3-fpm, using your PHP version, and confirm with php -m.
How do I install a PHP extension on AlmaLinux or Rocky Linux?
Find the package name with dnf search, install it with sudo dnf install php-intl or similar, then restart PHP with sudo systemctl restart php-fpm. Extensions missing from the base repositories are often in EPEL.
Should I still use CentOS for a new server?
No. CentOS Linux has reached end of life and no longer receives security updates. AlmaLinux and Rocky Linux are close replacements, and Ubuntu LTS and Debian are also widely used.
Does Domain India VPS include cPanel?
No. cPanel is not offered on Domain India VPS plans because of its licence cost. You can run a VPS without a panel or choose one of the optional panels listed on the VPS page, and shared cPanel hosting includes cPanel.
Can I install PHP extensions on shared hosting?
No. Shared servers use PHP builds shared by every account, so extensions can't be installed per account. Check what is loaded with extension_loaded(), try another PHP version, or open a ticket with the extension name and PHP version.
Ready to set up your server? Compare VPS plans, or if you are on shared hosting, check your extensions and open a support ticket with the extension name and PHP version.
Choose your Linux OS, get root access and install exactly the PHP version and extensions your application needs.
Compare VPS plans