Adding Custom PHP Module in Plesk
In Plesk 12.5, we have delivered a number of long-requested features and improvements in regard to PHP management. Multiple PHP versions out of the box? Check. PHP-FPM support? Yup. Support for PHP accelerators that drastically improve the performance of websites written in PHP? We got that. These improvements – and many more besides – are detailed in the Plesk 12.5 release notes (available in Linux and Windows flavors), but today I would like to tell you how Plesk 12.5 will give you even greater degree of control over PHP.
One of the new features we have delivered in Plesk 12.5 is the ability to switch individual PHP module for every PHP version installed on the server on or off easily and conveniently via the Plesk interface. Sounds great, but what if the desired module is not on the list? Never fear, Plesk 12.5 also gives you the ability to add custom PHP module to Plesk and make them available to your customers.
To add a module, you need to first download and install the necessary packages, them build the module, and finally register it in Plesk. The steps for the build procedure deviate very little from the standard PHP instructions, found here – just pay attention to the custom paths you will need to use.
I will illustrate the concept by adding the memcached php module for PHP 5.6 that comes pre-installed with Plesk 12.5. The commands in the example are for CentOS 7, but you can make use of this functionality on different OSes as well. You may need to alter the package names slightly, but the underlying principle remains the same.
We begin by downloading and installing the necessary packages:
# yum search plesk-php devel
# yum install make plesk-php56-devel gcc glibc-devel libmemcached-devel zlib-devel
Then we build the module:
# /opt/plesk/php/5.6/bin/pecl install memcached
(when prompted for the libmemcached directory, leave it blank and hit the Enter key)
And register it with Plesk:
# echo "extension=memcached.so" > /opt/plesk/php/5.6/etc/php.d/memcached.ini
# plesk bin php_handler --reread
And as they say in France, et voilà! You should now be able to see the extension in Tools & Settings > PHP Settings > *any PHP 5.6 handler*
As a final touch, to have the extension appear on the customers’ phpinfo pages, clear the checkbox, click OK, and wait for the changes to be applied, then select the checkbox and apply the changes once again.