Search K
Appearance
Appearance
The default PHP is compiled with most common modules and extensions. You may list all enabled modules simply by running this command:
php -mOr 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 https://www.php.net/manual/en/extensions.alphabetical.php
DirectAdmin already provides a set of possible extensions to be easily compiled using our CustomBuild tool, including:
bz2
gmp
htscanner
igbinary
imagick
imap
ioncube
ldap
lz4
mcrypt
opcache
phalcon
pgsql
redis
readline
ssh2
suhosin
snuffleupagus
xmlrpc
yaml
zend
zstdThose can be installed using the following commands:
da build set_php "imap" yes
da build "php_imap"We can add more extensions to the list. You can create a feature request here.
You may want to compile your PHP with a custom module. It can be done by using the --with-module flag.
da build used_configs | grep 'configure\.php'It might look like this:
PHP (default) configuration file: /usr/local/directadmin/custombuild/configure/php/configure.php74Please pay attention to whether your file is located in: /usr/local/directadmin/custombuild/**configure**/php/configure.php74 or/usr/local/directadmin/custombuild/**custom**/php/configure.php74
In case you're already using a custom configuration file, you can skip step 2.
Please specify which filename is currently in use:
cd /usr/local/directadmin/custombuild
mkdir -p custom/php
cp -fp "configure/php/configure.php74" "custom/php/configure.php74"da build phpsystemctl restart httpd
systemctl restart php-fpm74Please 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 foundwhich simply means that the \ character was not correctly added on the line before the last --with-module.
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.
Take a download location for a desired extension from https://www.php.net/manual/en/extensions.alphabetical.php
wget https://github.com/krakjoe/apcu/archive/master.zip
unzip master.zip
cd apcu-master
"/usr/local/php72/bin/phpize"
./configure --with-php-config="/usr/local/php72/bin/php-config"
make
make installThis will place an apcu.so file into the PHP extensions directory, which will be mentioned after make install finishes.
vi "/usr/local/php72/lib/php.conf.d/90-apcu.ini"and place the code inside:
extension=apcu.so
apc.enabled=1
apc.shm_size=1000M
apc.ttl=7200
apc.user_ttl=7200
apc.enable_cli=1
apc.max_file_size=5MReplace 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.
systemctl restart httpdNote: 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.