PHP Extensions

The default PHP is compiled with most common modules and extensions. You may list all enabled modules simply by running this command:

php -m

Or create a phpinfo() page and open it in a browser.

Various websites may require some additional modules and extensions. You may extend your PHP functionality by using our CustomBuild tool.

All extensions are mainly maintained by PECL, which stands for PHP Extension Community Library. It has extensions written in C, which can be loaded into PHP to provide additional functionality.

PHP maintains an alphabetical list of all the available extensions via the websiteopen in new window

Installing extensions

DirectAdmin already provides a set of possible extensions to be easily compiled using our CustomBuild tool, including:


Those can be installed using the following commands:

cd /usr/local/directadmin/custombuild
./build set_php "imap" yes
./build "php_imap"

We can add more extensions to the list. You can create a feature request hereopen in new window.

Add a custom module to PHP with CustomBuild

You may want to compile your PHP with a custom module. It can be done by using the --with-module flag.

  1. First, let's figure out which configuration file your system is using. Type:
cd /usr/local/directadmin/custombuild
./build used_configs | grep configure.php

It might look like this:

PHP (default) configuration file: /usr/local/directadmin/custombuild/configure/php/configure.php74

Please pay attention to whether your file is located in: /usr/local/directadmin/custombuild/**configure**/php/configure.php74 or

In case you're already using a custom configuration file, you can skip step 2.

Please specify which filename is currently in use:

  1. To start customizing the compilation parameters, first we need to create a custom compilation file:
cd /usr/local/directadmin/custombuild
mkdir -p custom/php
cp -fp "configure/php/configure.php74" "custom/php/configure.php74"
  1. Add your --with-module line to the end of the custom/php/{{configurephp}} file, and make sure the \ character exists at the end of all lines except the last one. The \ character tells the configure line to loop to the next line, making the line easier to read. Without the \ character to trigger the wrap, the next line is incorrectly read as a separate command. Once set, type:
./build php
  1. Restart Apache and if necessary, PHP-FPM.
systemctl restart httpd
systemctl restart php-fpm74

Please keep in mind that any changes to your stock DirectAdmin setup are beyond our technical support, and you do so at your own risk.

A common error people run into looks like this:

/usr/local/directadmin/custombuild/custom/php/configure.php74: line 32: --with-module: command not found

which simply means that the \ character was not correctly added on the line before the last --with-module.

Manually compiling an extension for PHP

Consider the example using the APCu extension for PHP version (without dots e.g. 56, 70, 71).

Where possible, use OpCache instead of APC/APCu.

A common optimization that can be done for PHP to improve performance is to install and Opcode caching module such as Alternative PHP Cache (APCu, or APC for php version < 5.6).

What it does is caches PHP files in memory in their parsed and compiled state. This removes the need for re-reading, parsing and compiling for each request, thus greatly lowering your system load. The cost of using this module is an increased memory usage, since that's where the cache lives.

  1. Download, compile and install the module.

Take a download location for a desired extension from

cd apcu-master
./configure --with-php-config="/usr/local/php72/bin/php-config"
make install

This will place an file into the PHP extensions directory, which will be mentioned after make install finishes.

  1. Add a custom ini file and enable the extension:
vi "/usr/local/php72/lib/php.conf.d/90-apcu.ini"

and place the code inside:

Replace the 1000M with the amount of RAM you want it to use. About 40M per WordPress installation and 60M per Magento installation should be sufficient. Multiply that by the number of installations. For example, 100 WordPress installs = 4000M.

If your server does not have enough RAM to cache all of the PHP files, you must reduce the number of cached files. Use the filters option or play with the cache_by_default option to specify which files to be cached. A tip is to set apc.cache_by_default=0 in php.ini, and then apc.cache_by_default=1 in the .htaccess of the websites requiring APC optimization.

  1. Restart Apache:
systemctl restart httpd

Note: APC provides a tool to check memory usage. It's a PHP page that you will find in apcu-master/apc.php. Copy the file to a web folder and open it in a web browser. In a correctly configured APC installation, the memory chart must remain stable over time.

If you have multiple versions of PHP available with CustomBuild, you have to compile the custom extension for each version.

Last Updated: