Installing and enabling PHP extensions in DirectAdmin
Any PHP extension available on PECL can be installed and enabled on any PHP version supported by DirectAdmin. This guide uses memcache on PHP 7.4 as an example — adjust the PHP version paths and download URLs for your specific extension.
For built-in extensions that don’t require compilation, see Enabling PHP extensions with DirectAdmin.
Download and extract the package
Section titled “Download and extract the package”Log in to your compute via SSH as root, then download and extract the extension:
cd /tmpwget https://pecl.php.net/get/memcache-4.0.5.1.tgztar -zxvf memcache-4.0.5.1.tgzcd memcache-4.0.5.1Configure and compile the extension
Section titled “Configure and compile the extension”DirectAdmin stores PHP binaries at /usr/local/phpXX/bin (e.g., /usr/local/php74/bin for PHP 7.4).
Run phpize to prepare the build environment:
/usr/local/php74/bin/phpizeConfigure the extension:
./configure --with-php-config=/usr/local/php74/bin/php-configCompile and install:
makemake installThe output will show the extensions directory, e.g.:
Installing shared extensions: /usr/local/php74/lib/php/extensions/no-debug-non-zts-20190902/Verify the .so file is present:
ls -la /usr/local/php74/lib/php/extensions/no-debug-non-zts-20190902/Enable the extension in php.ini
Section titled “Enable the extension in php.ini”Open the PHP configuration file for your version (e.g., /usr/local/php74/lib/php.ini) and:
-
Find
extension_dir(typically commented out by default). Uncomment it and set the path:extension_dir = "/usr/local/php74/lib/php/extensions/no-debug-non-zts-20190902/" -
At the end of the file, add:
extension=memcache.so -
Restart the web server:
systemctl restart httpd.service -
Verify the extension is loaded:
/usr/local/php74/bin/php -m