Plesk & SocialBee have teamed up. Save 30% now!

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*

Php module - Memcached

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.

31 Comments

  1. Thanks!

    And for Version 12.0 ?. I tried but fails. 🙁
    ———
    Error: Paquete: plesk-php56-devel-5.6.11-centos6.15071310.x86_64 (plesk-php-5.6)
    Necesita: plesk-php56 = 5.6.11-centos6.15071310
    Instalado: plesk-php56-5.6.12-centos6.15081013.x86_64 (@PHP_5_6_12-dist)
    plesk-php56 = 5.6.12-centos6.15081013
    Disponible: plesk-php56-5.6.11-centos6.15071310.x86_64 (plesk-php-5.6)
    plesk-php56 = 5.6.11-centos6.15071310
    ———

    • Juanjo,

      There are some issues with the links to the appropriate URL for the PHP 5.6.12 development packages and I already reported that to Odin Team, so a solution should follow quickly.

      However, you should be able to use the plesk-php56-dev(el) package for both PHP versions 5.6.11 and 5.6.12. That is, in theory, I did not investigate that (yet).

      Note that the whole article is aimed at the Plesk 12.5 (i.e. Preview version).

      The setup for Plesk 12.0.18 (current stable version) is somewhat different:

      a) uninstall previously installed packages: plesk-php56-dev(el)

      b) determine what you want:

      – the PECL memcache extension: an extension to communicate with memcached (a daemon server),
      – the PECL memcached extension: a more complex and feature rich extension that uses the libmemcached library to communicate with memcached (a daemon server),

      and particularly note the differences between, on the one hand, memcache and memcached (both being extensions, i.e. “modules”) and, on the other hand, memcached (the “module”) and the server memcached, which has to be installed anyway.

      For now, I will assume that you will want the PECL memcache extension, since it will suffice in many situations and certainly for WordPress AND for the reason that another PECL extension is not present in plesk-php56-dev(el) packages.

      c) install memcached server (if it is not installed already) with:

      – yum install memcached (RedHat/CentOS)
      – apt-get install memcached (Ubuntu/Debian)

      and check whether memcached server is running, otherwise start the memcached server.

      d) install plesk-php56-dev(el) package, by using

      – yum install plesk-php56-devel (RedHat/CentOS)
      – apt-get install plesk-php56-dev (Ubuntu/Debian)

      and this should install the proper version of the PHP development packages,

      OR, when encountering issues with the installation of the packages, use a work-around:

      – wget http://autoinstall.plesk.com/PHP_5.6.11//extra/
      – install the manually

      with being the appropriate distribution and the associated package.

      Note that the PHP development packages are called plesk-php56-dev on Ubuntu/Debian and plesk-php56-devel on RedHat/CentOS. This slight difference in names can make a difference.

      e) login with SSH and change directory to /opt/plesk/php/5.6/bin and run

      – ./pecl install memcache
      – echo “extension=memcached.so” > /opt/plesk/php/5.6/etc/php.d/memcached.ini

      and (afterwards) restart

      – Apache webserver, AND
      – PHP5-FPM, if you are using the fpm module.

      And that is all that has to be done.

      Some remarks have to made though:

      1) when using the yum/apt-get install option, it is not certain which version (5.6.11 or 5.6.12) will be installed, given the issues with the URLs, as mentioned before.

      In essence, the 5.6.12 should be installed by default, it should work and for that reason, the work-around to install version 5.6.11 should not be preferred or not even be necessary.

      2) it is possible to use memcached (server) to store PHP sessions.

      This is certainly not adviced, so I will skip the instruction on how to configure settings.

      3) it is possible to use memcached (server) with the memcache extension to improve general performance of WordPress sites.

      In this scenario, it is best to install the W3 Total Cache plugin in WordPress and select the option “Memcached” for Page Cache, Object Cache and/or Database Cache.

      Note that Database Caching is not always optimal in WordPress installations.

      4) it is possible to use other kinds of cache servers, such as Redis.

      In fact, Redis Cache is more advanced, more flexible than Memcached Server and will always outperform Memcached Server.

      However, Memcached Server with the memcache or memcached extension is rather simple to install and/or to maintain, whilst Redis Server can require some extra work and knowledge.

      Hope the above helps.

      If you have questions, just ask here or on the Odin forum.

      Kind regards…

      • Thank you so much! I hadn’t found this information among the Plesk documentation, I googled it and found your response. This is working for me to install pecl extensions in php 5.6 for Plesk 12.0.18

      • Hi Trialotto!
        I installed all of your instructions. memcached server and plesk-php56-dev(el) package. All without errors. But WordPress Totap Cache, Super Cache and other plugins for support Memcached – not see memcahed. In SMF – the same problem.
        I’ve already tried to reinstall. Check php info, check status memcahe – all fine.
        Why they do not see memcached ?

        • Hi, I had the same issue as Trialotto, and the way I got it to work with WordPress plugins was in pecl uninstall memeched and pecl install memcahe

          Very useful post!

  2. Juanjo,

    Just got notice that the URL issues are resolved: the plesk-php56-dev(el) package (version 5.6.12) is accessible from the link http://autoinstall.plesk.com/PHP_5.6.12/“distribution”/extra/”package”

    Note that in my earlier post, the “distribution” and “package” mark-up has been automatically removed by the “forum engine”, hope that this explanation helps.

    Regards….

  3. it’s possible to have an example for debian?

  4. Thank you for such detailed article. Very cool. Liked it.

  5. Hello;

    when is Plesk 12.5 will be available for production?

  6. I upgraded to plesk 12.5

    When I try to install mencached, I get this error:

    configure: error: no, sasl.h is not available. Run configure with –disable-memcached-sasl to disable this check
    ERROR: `/tmp/memcached/configure –with-libmemcached-dir=no’ failed

    I’ve tried different solutions searching the web, but none has worked.

    Any ideas?

    Thanks

    • @Juanjo,

      In the case of an upgrade to 12.5.30, one should again follow the normal procedure, as stated by the article.

      You should check the various config files, in order to determine which version of php is running and which version of php is using the module memcache or memcached (and so on).

      In general, it is more easy to do a clean install of the module (being memcached in Plesk 12.5.30) and, if that does not help, remove all memcache/memcached modules and retry the clean install.

      Hope this helps a bit.

      Kind regards….

  7. Tried this with APCu with php56-fpm. Can activate it now in Plesk but APCu still not present in my TYPO3 Installation 🙁

  8. Got an error when compiling memcache for php7. It makes until the configure. The error comes when “make” comes in:

    …..
    checking whether to build static libraries… no
    configure: creating ./config.status
    config.status: creating config.h
    config.status: executing libtool commands
    running: make
    /bin/sh /tmp/pear-build-rootTZU8AM/memcache-2.2.7/libtool –mode=compile cc -I/opt/plesk/php/7.0/include/php -I. -I/tmp/memcache -DPHP_ATOM_INC -I/tmp/pear-build-rootTZU8AM/memcache-2.2.7/include -I/tmp/pear-build-rootTZU8AM/memcache-2.2.7/main -I/tmp/memcache -I/opt/plesk/php/7.0/include/php -I/opt/plesk/php/7.0/include/php/main -I/opt/plesk/php/7.0/include/php/TSRM -I/opt/plesk/php/7.0/include/php/Zend -I/opt/plesk/php/7.0/include/php/ext -I/opt/plesk/php/7.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/memcache/memcache.c -o memcache.lo
    libtool: compile: cc -I/opt/plesk/php/7.0/include/php -I. -I/tmp/memcache -DPHP_ATOM_INC -I/tmp/pear-build-rootTZU8AM/memcache-2.2.7/include -I/tmp/pear-build-rootTZU8AM/memcache-2.2.7/main -I/tmp/memcache -I/opt/plesk/php/7.0/include/php -I/opt/plesk/php/7.0/include/php/main -I/opt/plesk/php/7.0/include/php/TSRM -I/opt/plesk/php/7.0/include/php/Zend -I/opt/plesk/php/7.0/include/php/ext -I/opt/plesk/php/7.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/memcache/memcache.c -fPIC -DPIC -o .libs/memcache.o
    /tmp/memcache/memcache.c:40:40: error: ext/standard/php_smart_str.h: No existe el fichero o el directorio
    En el fichero incluído de /tmp/memcache/memcache.c:42:
    /tmp/memcache/php_memcache.h:38:47: error: ext/standard/php_smart_str_public.h: No existe el fichero o el directorio
    /tmp/memcache/memcache.c: En la función ‘OnUpdateChunkSize’:
    /tmp/memcache/memcache.c:138: aviso: se pasa el argumento 1 de ‘strtol’ desde un tipo de puntero incompatible
    /usr/include/stdlib.h:184: nota: se esperaba ‘const char * __restrict__’ pero el argumento es de tipo ‘struct zend_string *’
    /tmp/memcache/memcache.c:144: error: ‘new_value_length’ no se declaró aquí (primer uso en esta función)
    /tmp/memcache/memcache.c:144: error: (Cada identificador no declarado solamente se reporta una vez
    /tmp/memcache/memcache.c:144: error: para cada funcion en la que aparece.)
    /tmp/memcache/memcache.c: En la función ‘OnUpdateFailoverAttempts’:
    /tmp/memcache/memcache.c:152: aviso: se pasa el argumento 1 de ‘strtol’ desde un tipo de puntero incompatible
    ……

  9. Hi, that’s nice; however, I get the following when executing the pecl install for php 7.0:

    pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.0
    No valid packages found

  10. @Everyone,

    I did not look at this DevBlog page for a long time and I just noticed that some of you have some problems with

    – memcache modules for other versions of PHP, especially PHP 7.0.x
    – integration with third-party components, like WordPress plugins and/or Typo3

    In the meantime, I have compiled a Redis module for PHP 7.0.x, this module can be downloaded from the Plesk forum.

    I suggest that I open an additional thread, in order (on the one hand) to allow you to discuss and mention the issues and problems encountered and (on the other hand) to allow me to do some additional research and potential problem solving.

    The topic thread on the Plesk forum: http://talk.plesk.com/threads/redis-module-for-php-7-0-1-and-7-0-2.336648/

    Please make a short remark or request and refer to your comments on this page, this for the sake of convenience.

    Any suggestions are welcome!

    Regards…..

  11. Hi, there seems to be a problem with PHP 7.02

    /opt/plesk/php/7.0/bin/pecl install memcached
    pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.2
    No valid packages found
    install failed

  12. /opt/plesk/php/7.0/bin/pecl install memcached
    pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.3
    No valid packages found
    install failed

    I have the same exact problem

  13. Hello there! Quick question that’s entirely off topic.
    Do you know how to make your site mobile friendly? My weblog looks weird when viewing from my iphone4.
    I’m trying to find a template or plugin that might be able to correct this
    issue. If you have any recommendations, please share.

    Thanks!

  14. I know this website provides quality dependent posts and other data,
    is there any other website which offers these kinds of information in quality?

  15. Hi,

    I found this link may useful for someone. I follow these post and i success to install on my Plesk 12.5

    https://talk.plesk.com/threads/error-installing-mencached-plesk-12-5-centos-6-7.335075/

  16. If I wanted to install the mssql module which commands should I give?

    In command line is yum install php-mssql.

  17. I know this website presents quality dependent posts
    and additional information, is there any other website which gives such stuff in quality?

  18. I tried to install the APCu module for php 5.6 on my Plesk Onyx 17.0.17/Ubuntu 16.04 LTS:

    root@vps:/opt/plesk/php/5.6/bin# ./pecl install apcu
    pecl/apcu requires PHP (version >= 7.0.0-dev), installed version is 5.6.30
    pecl/apcu requires PEAR Installer (version >= 1.10), installed version is 1.9.4
    No valid packages found
    install failed

    Can anyone help ?

  19. What about for Plesk for Windows?

  20. What about things like mail() and getimagesize()?

  21. pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.6.31

    • i get this error

      [root@host04 bin]# /opt/plesk/php/5.6/bin/pecl install memcached
      pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.6.31
      pecl/memcached can optionally use PHP extension “igbinary” (version >= 2.0)
      pecl/memcached can optionally use PHP extension “msgpack” (version >= 2.0)
      No valid packages found
      install failed

  22. php_bin /opt/plesk/php/5.6/bin/php appears to have a suffix /5.6/bin/php, but config variable php_suffix does not match

Add a Comment

Your email address will not be published. Required fields are marked *

GET LATEST NEWS AND TIPS

  • Yes, please, I agree to receiving my personal Plesk Newsletter! WebPros International GmbH and other WebPros group companies may store and process the data I provide for the purpose of delivering the newsletter according to the WebPros Privacy Policy. In order to tailor its offerings to me, Plesk may further use additional information like usage and behavior data (Profiling). I can unsubscribe from the newsletter at any time by sending an email to [email protected] or use the unsubscribe link in any of the newsletters.

  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden

Related Posts

Knowledge Base