Server Management (Unmanaged)

How to Enable Essential PHP Extensions on a VPS with CentOS and cPanel

By the Domain India teamPublished 9 min read
Knowledge base article
Contents (9 sections)

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.

Key takeaways

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.

ExtensionWhat it doesUsually
opensslEncryption and TLS connectionsBuilt in
jsonJSON encoding and decodingBuilt in since PHP 8.0
ctypeCharacter checks, such as "digits only"Built in on most builds
tokenizerParses PHP code, used by frameworksBuilt in on most builds
pdo_mysqlDatabase access through PDOPackage
mysqliMySQL access, used by WordPressPackage
mbstringHandles UTF-8 and non-Latin textPackage
xml, domReads and writes XMLPackage
intlLocale-aware numbers, dates and sortingPackage
curlHTTP requests to APIsPackage
gd or imagickImage resizing and thumbnailsPackage
zipZIP archives, used by updates and importsPackage
fileinfoDetects file types for safe uploadsBuilt in on most builds
exifReads photo metadataPackage or built in
bcmathExact decimal mathsPackage

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:

bash
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
<?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.

  1. Refresh the package list.
    Run sudo apt update.
  2. 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. The php-mysql package provides both mysqli and pdo_mysql.
  3. Check the extension is switched on.
    Debian-based systems enable new extensions automatically. You can switch one on or off with sudo phpenmod intl or sudo phpdismod intl.
  4. Restart PHP.
    Run sudo systemctl restart php8.3-fpm, using your version number, or sudo systemctl restart apache2 if PHP runs as an Apache module.
  5. Confirm
    with php -m and 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.

  1. Find the package. Run `dnf search php-
    grep -i intl` to see the exact name on your release.
  2. Install what you need.
    For example: sudo dnf install php-mysqlnd php-mbstring php-xml php-intl php-gd php-bcmath php-opcache. Here php-mysqlnd provides mysqli and pdo_mysql.
  3. Restart PHP.
    Run sudo systemctl restart php-fpm, and restart the web server (httpd or nginx) if you changed its configuration.
  4. Confirm
    with php -m and 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:

bash
sudo pecl install redis

You 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.

Leave dead extensions behind

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 use extension_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.

VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details
cPanel Growth
₹200/mo + GST
  • 50 GB NVMe SSD Storage
  • 100 GB Monthly Bandwidth
  • 5 Websites
  • 50 Email Accounts
See plan details

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.

Need a server you fully control?

Choose your Linux OS, get root access and install exactly the PHP version and extensions your application needs.

Compare VPS plans

Ready when you are

Get VPS from ₹552.65/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Enable PHP Extensions on a VPS: apt, dnf, PECL