Native support of PHP extensions in DirectAdmin

DirectAdmin can install the following PHP extensions as of August 2021:

  • bz2
  • GMP
  • htscanner
  • imagination
  • imap
  • ioncube
  • LDAP
  • opcache
  • falcon
  • line to read
  • say it again
  • snuffleupagus
  • suhosin
  • xmlrpc
  • Zend

The listed extensions can only be installed server-wide, i.e. for all existing users and their domains.

Extensions cannot be selectively installed for PHP versions. They will be installed for all PHP versions enabled in CustomBuild’s options.conf. And make sure some of them will fail to compile for PHP 5.x and some for PHP 7.x.

Enable PHP Extensions in DirectAdmin

First change the directory to CustomBuild:

cd /usr/local/directadmin/custombuild

Depending on which extension you want to enable, you can run all or any of the following commands:

./build set_php bz2 yes
./build set_php gmp yes
./build set_php htscanner yes
./build set_php imagick yes
./build set_php imap yes
./build set_php ioncube yes
./build set_php ldap yes
./build set_php opcache yes
./build set_php phalcon yes
./build set_php readline yes
./build set_php redis yes
./build set_php xmlrpc yes
./build set_php zend yes

Enhanced security for PHP (before 7.x):

./build set_php suhosin yes

Improved security for PHP (7.x and newer):

./build set_php snuffleupagus yes

You can either set up ready-made safety rules for “snuffleupagus” or create your own set of rules. Although this is the subject of a separate article. And it will not be covered here.

Disable PHP Extensions in DirectAdmin:

First change the directory to CustomBuild:

cd /usr/local/directadmin/custombuild

Depending on which extension you want to disable, you can run all or any of the following commands:

./build set_php bz2 no
./build set_php gmp no
./build set_php htscanner no
./build set_php imagick no
./build set_php imap no
./build set_php ioncube no
./build set_php ldap no
./build set_php opcache no
./build set_php phalcon no
./build set_php readline no
./build set_php redis no
./build set_php snuffleupagus no
./build set_php suhosin no
./build set_php xmlrpc no
./build set_php zend no

Install/Update PHP Extensions in DirectAdmin:

First change the directory to CustomBuild:

cd /usr/local/directadmin/custombuild

Depending on which extension you want to install/update, you can run all or any of the following commands:

./build php_bz2
./build php_gmp
./build php_htscanner
./build php_imagick
./build php_imap
./build php_ioncube
./build php_ldap
./build php_opcache
./build php_phalcon
./build php_readline
./build php_redis
./build php_snuffleupagus
./build php_suhosin
./build php_xmlrpc
./build php_zend

Set all PHP extensions set in php_extensions.conf

If you want to rebuild or update all enabled PHP extensions in DirectAdmin, run the following command:

cd /usr/local/directadmin/custombuild 
./build update
./build php_extensions

Full list of commands to install PHP imap extension:

Let’s list all the commands in one snippet that you will need to run as root in order to install PHP imap extension on DirectAdmin server. They would be the following:

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

If you see the following or similar error:

Cannot build imap, because you do not have it set in php_extensions.conf file.

You have to run first:

./build set_php imap yes

where to changeimap“With a required extension and try again.

That’s it.

ps thanks noel for a response.

Leave a Comment