Security

Add Custom PHP Modules with Custombuild in DirectAdmin

Custom PHP Modules ,PHP is a open source script which mainly used to create or build static and dynamic pages. PHP is supported by all linux web servers.

PHP modules, also known as PHP extensions, are libraries of functions that add specific capabilities to the PHP programming language. These extensions are compiled into PHP and can be dynamically loaded or statically linked to enhance PHP’s functionality.

It can be compiled with PHP to enable static loading or dynamic loading. PHP modules are used for different purposes with only a few extensions.

It play a crucial role in enhancing the capabilities, performance, security, and maintainability of PHP applications,

Various websites may require some additional modules and extensions. You may extend your PHP functionality by using our Custom Build 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 php.net website

Single PHP Version

If your server only has a single PHP version installed, you can run this PHP command anywhere, and it will give you the same list of modules. The general command we will be using is php -m. This command will give you the full list of installed PHP modules/extensions.

[root@dedicated ~]# php -m

This command will give you an output similar to the following information.

Custom PHP Modules

 

Custom PHP Modules Installing extensions

Most of all control panel provides a set of possible extensions to be already complied by default. Here 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
opcache
phalcon
redis
readline
suhosin
snuffleupagus
xmlrpc
zend

Those can be installed using the following commands: For example if you need to compile ioncube

Than use the below commands,

cd /usr/local/directadmin/custombuild
./build set_php "ioncube" yes
./build "php_ioncube"

We can add more extensions to the list.

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.

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

Be ware to whether your files 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 the above step

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"

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

Restart Apache and if necessary, PHP-FPM.

systemctl restart httpd
systemctl restart php-fpm74

If any error occured during the above process just looks like

/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.