PHP Development

Installing PHP Extensions and Complex Libraries Across Various Operating Systems and Control Panels

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

PHP extensions add abilities to PHP itself, such as image handling, international text or database drivers. PHP libraries are plain PHP code that your project pulls in with Composer. This guide explains the difference, shows how to install extensions on the common Linux systems, Windows and the main control panels on a server you manage, and explains what you can and can't do on shared hosting.

Key takeaways

Extensions are installed at server level: with apt on Ubuntu or Debian, dnf on AlmaLinux or Rocky Linux, php.ini on Windows, EasyApache 4 on a cPanel server, CustomBuild on a DirectAdmin server and the PHP settings in Plesk. After installing, restart PHP-FPM or the web server and check with php -m and a test page. Libraries are installed per project with Composer. On shared hosting you can't install extensions or run Composer: check what is loaded, switch PHP version if needed, ask support, and upload your vendor folder built elsewhere.

1. Extensions and libraries are different things

AspectPHP extensionPHP library
Written inC, compiled for a PHP versionPHP
Examplesintl, gd, imagick, mbstring, pdo_mysql, redisguzzlehttp/guzzle, monolog/monolog, phpmailer/phpmailer
Installed byThe server administratorYou, per project, with Composer
Where it livesThe server's PHP buildYour project's vendor folder

When an application says "requires the intl extension", that is a server job. When it says "run composer require", that is a project job. Libraries often depend on extensions: a line such as "ext-intl": "*" in composer.json means the server must have intl.

2. Check what is already loaded

bash
php -v                  # the command-line PHP version
php -m                  # extensions loaded by command-line PHP
php --ini               # which php.ini files are read

The website can use a different PHP version or configuration from the command line. Confirm with a small test page, then delete it:

php
<?php
foreach (['intl', 'gd', 'mbstring', 'pdo_mysql', 'zip'] as $ext) {
    echo $ext, ': ', extension_loaded($ext) ? 'loaded' : 'missing', "\n";
}

3. Ubuntu and Debian

bash
sudo apt update
sudo apt install php-intl php-gd php-mbstring php-zip     # for the default PHP version
sudo apt install php8.3-intl                              # or name the version explicitly
sudo systemctl restart php8.3-fpm                         # with Nginx or Apache + PHP-FPM
sudo systemctl restart apache2                            # with Apache's PHP module

Match the version prefix to the PHP you actually run (php -v). Mixing versions is the most common reason an "installed" extension doesn't load.

4. AlmaLinux, Rocky Linux and Fedora

bash
sudo dnf install php-intl php-gd php-mbstring php-zip php-pdo php-mysqlnd
sudo systemctl restart php-fpm
sudo systemctl restart httpd          # or nginx

On version 9, a newer PHP than the default comes from a module stream: sudo dnf module list php, then sudo dnf module enable php:8.3. Version 10 dropped module streams, so check dnf list php for the version it ships. Some extras come from the EPEL repository (sudo dnf install epel-release). CentOS Linux is end of life; use AlmaLinux or Rocky Linux instead, and dnf in place of yum.

Extensions not packaged by your distribution can be built from source. PECL has long been the tool for this; the PHP Foundation's newer installer, PIE, is the recommended route for current PHP versions. Both need build tools and PHP development headers (php-devel or php8.3-dev). The full Linux walkthrough is in enabling essential PHP extensions on a VPS.

5. Windows

The official Windows builds of PHP ship most extensions as DLL files in the ext folder; you enable them in php.ini:

  1. Find php.ini.
    Run php --ini, or look in the PHP installation folder.
  2. Check the extension folder.
    extension_dir = "ext" should point to the folder that holds the DLLs.
  3. Enable the extension.
    Remove the leading semicolon, for example change ;extension=intl to extension=intl. Since PHP 8 you write just the name, without php_ or .dll.
  4. Restart.
    Restart Apache, or on IIS recycle the site's application pool (or run iisreset on a server you administer).

Download extra extensions only as DLLs built for your exact PHP version, architecture (x64) and thread-safety type (NTS for IIS with FastCGI).

6. Servers with a control panel

On a server with a control panel, use the panel's own tool so updates don't undo your change.

PanelWhere extensions are managedNotes
cPanel & WHMWHM › Software › EasyApache 4 › Customize › PHP Extensions, then Review and ProvisionPackage names include the version, e.g. ea-php83-php-intl
DirectAdminCustomBuild (in the admin panel, or ./build on the command line)Rebuilds PHP with the chosen options
PleskTools & Settings › PHP Settings for the handler, or Updates › Add/Remove ComponentsScreens vary between Plesk versions

All three need administrator (root) access. For DirectAdmin details, see installing and managing PHP extensions in DirectAdmin.

Retired extensions

Old guides still mention mcrypt, xmlrpc and suhosin. They are not part of modern PHP. An application that still asks for them needs updating; use sodium or openssl in place of mcrypt.

7. Libraries with Composer

Composer installs the libraries a project needs and generates an autoloader:

bash
composer require guzzlehttp/guzzle
composer install --no-dev --optimize-autoloader     # for production
php
<?php
require __DIR__ . '/vendor/autoload.php';

Commit composer.json and composer.lock, not vendor, to version control. On production, run composer install, never composer update, so you get exactly the versions you tested. See installing Composer and using it to manage PHP libraries.

8. On Domain India shared hosting

On our cPanel and DirectAdmin shared hosting the PHP builds are shared by every account on the server:

  • You can't install extensions. A php.ini or .user.ini line such as extension=redis.so does nothing, and dl() is disabled. The common extensions are already loaded.
  • You can choose the PHP version. cPanel offers PHP up to 8.5, with 8.3 as the default for new accounts; DirectAdmin offers up to 8.3. Each version has its own set of extensions.
  • You can't run Composer on the server. It needs functions such as proc_open, which are disabled on shared hosting, even over jailed SSH. Run composer install on your computer or in CI with the same PHP version, then upload the project with its vendor folder.
  • Some functions are off even when the extension is loaded. See PHP disabled functions on shared hosting.
  • Windows (Plesk) hosting supports PHP alongside .NET; ask support about a specific extension.

If an extension is missing, open a ticket with the domain, PHP version and extension name, and support will tell you whether it can be provided or needs a VPS. Some, such as Redis or MongoDB drivers, need a background service that shared hosting doesn't offer.

For full control over PHP and its extensions, a Domain India VPS gives you root access. It is self-managed, and cPanel isn't offered on it; the optional panels are listed on the VPS page.

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 Starter
₹125/mo + GST
  • 25 GB NVMe SSD Storage
  • 50 GB Monthly Bandwidth
  • 1 Website
  • 10 Email Accounts
See plan details

Prices on the cards are live Domain India list prices and exclude 18% GST.

Frequently asked questions

What is the difference between a PHP extension and a PHP library?

An extension is compiled C code loaded by the server's PHP, such as intl or gd, and is installed by the server administrator. A library is PHP code, such as Guzzle, installed into your project's vendor folder with Composer.

How do I install a PHP extension on Ubuntu?

Run sudo apt install php-name, or php8.3-name for a specific version, then restart PHP-FPM or Apache. Check with php -m and a test page that calls extension_loaded.

How do I enable an extension on Windows?

Open php.ini, make sure extension_dir points to the ext folder, remove the semicolon in front of the extension line, for example extension=intl, and restart the web server or recycle the IIS application pool.

Can I install PHP extensions on Domain India shared hosting?

No. The PHP builds are shared by every account, so extensions can't be added per account. Check what is loaded, try another PHP version, or open a ticket with the extension name and PHP version.

Can I run Composer on shared hosting?

No. Composer needs functions such as proc_open that are disabled on Domain India shared hosting. Run composer install on your computer or in CI and upload the project including the vendor folder.

Why does my extension show in php -m but not on my website?

The command line and the website can use different PHP versions or php.ini files. Restart PHP-FPM, and check the website with a test page rather than the command line.

Ready to set up PHP your way? Compare VPS plans for full control, or open a support ticket with the extension name and PHP version if you're on shared hosting.

Need a PHP extension?

Tell us your domain, PHP version and the extension your application needs, and we will tell you what is possible.

Open a support ticket

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
Install PHP Extensions on Linux, Windows and Panels