DirectAdmin can install the following PHP extensions as of August, 2021:
The listed extensions can be installed server-wide only, i.e. for all existing users and their domains.
The extensions can not be installed for PHP versions selectively. They will be installed for all PHP versions enabled in options.conf of CustomBuild. And sure some of them will fail to compile for PHP 5.x and some for PHP 7.x.
First change directory to custombuild:
cd /usr/local/directadmin/custombuild
You can run all or any of the following commands depending on what extension you want to enable:
./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 (prior to 7.x):
./build set_php suhosin yes
Enhanced security for PHP (7.x and newer):
./build set_php snuffleupagus yes
You might either install ready security rules for "snuffleupagus" or prepare your own set of rules. This is a subject for a separate article though. And it won't be covered here.
First change directory to custombuild:
cd /usr/local/directadmin/custombuild
You can run all or any of the following commands depending on what extension you want to disable:
./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
First change directory to custombuild:
cd /usr/local/directadmin/custombuild
You can run all or any of the following commands depending on what extension you want to install/update:
./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
If you want to rebuild or update all enabled PHP extensions in DirectAdmin run the following commands:
cd /usr/local/directadmin/custombuild ./build update ./build php_extensions
Let's list all commands in one snippet that you will need to run as root to install PHP imap extension on a DirectAdmin server. They will be the following:
cd /usr/local/directadmin/custombuild ./build update ./build set_php imap yes ./build php_imap
If you see the following or a similar error:
Cannot build imap, because you do not have it set in php_extensions.conf file.
You will need to run first:
./build set_php imap yes
Where replace "imap" with a needed extension and try again.
That's it.
p.s. Thanks to Noel for a feedback.