How to install/uninstall memcached extension for Plesk PHP 7.x handlers?

Follow

Comments

56 comments

  • Avatar
    Lethalmiko

    All these instructions don't work on Ubuntu 18.04.2 LTS with Plesk Onyx 17.8.11 Update #48. I am running nginx as a full front-line web server with FPM, not as a proxy. PHP version 7.2.15 supplied by vendor. The phpinfo does not show  memcached support. I verified that memcached is working. It is memcached version 1.5.6.

    I did two methods and they both failed!!! I uninstalled everything in between the two methods. I am stuck and don't know what to do.

    METHOD 1:
    # apt autoremove
    # apt install memcached
    # apt install autoconf automake gcc libmemcached-dev libhashkit-dev pkg-config plesk-php72-dev zlib1g-dev libsasl2-dev build-essential php7.2-dev
    # /opt/plesk/php/7.2/bin/pecl install memcached
    # echo "extension=memcached.so" > /opt/plesk/php/7.2/etc/php.d/memcached.ini
    # plesk bin php_handler --reread
    # /etc/init.d/php7.2-fpm restart && /etc/init.d/apache2 restart && /etc/init.d/nginx restart

    METHOD 2:
    # apt autoremove
    # apt install memcached
    # apt install autoconf automake gcc libmemcached-dev libhashkit-dev pkg-config plesk-php72-dev zlib1g-dev libsasl2-dev build-essential php7.2-dev

    [Edit pecl file]
    # nano /usr/share/psa-pear/pear/pecl
    ---
    Removed -n flag from the last line of /usr/share/psa-pear/pear/pecl utility. It is now:

    exec $PHP -C -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
    ---

    # /opt/plesk/php/7.2/bin/pecl install memcached
    # echo "extension=memcached.so" > /etc/php/7.2/cli/conf.d/20-memcached.ini
    # plesk bin php_handler --reread
    # /etc/init.d/php7.2-fpm restart && /etc/init.d/apache2 restart && /etc/init.d/nginx restart

    0
    Comment actions Permalink
  • Avatar
    Nikita Nikushkin

    Hi @Lethalmiko,

    The provided solution is valid for Plesk PHP handlers only and does not work for system PHP

    I updated the article in order to avoid this misunderstanding and added the installation steps for "memcached" for OS PHP to the "Additional information" section as well

    Here are the steps for "memcached" installation for OS PHP:

    # apt install memcached
    # apt-get install php-memcached
    # plesk bin php_handler --reread
    # service apache2 restart
    # service php72-fpm restart

    After this, PHP info page started returning the "memcached"

    0
    Comment actions Permalink
  • Avatar
    Lethalmiko

    @Nikita Nikushkin

    I actually ended up solving the problem myself with more research. What I did:

    ---

    # apt autoremove
    # apt install memcached
    # apt install autoconf automake gcc libmemcached-dev libhashkit-dev pkg-config plesk-php72-dev zlib1g-dev libsasl2-dev build-essential php7.2-dev

    # nano /usr/share/psa-pear/pear/pecl

    ---

    [Edited pecl file]

    Remove -n flag from the last line of /usr/share/psa-pear/pear/pecl utility. It is now:

    exec $PHP -C -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"

    ---

    # /usr/share/psa-pear/pear/pecl install memcached
    [Installs to '/usr/lib/php/20170718/memcached.so']

    # echo "extension=memcached.so" > /etc/php/7.2/mods-available/memcached.ini
    # ln -s /etc/php/7.2/mods-available/memcached.ini /etc/php/7.2/cli/conf.d/20-memchached.ini
    # ln -s /etc/php/7.2/mods-available/memcached.ini /etc/php/7.2/fpm/conf.d/20-memchached.ini
    # plesk bin php_handler --reread
    # /etc/init.d/php7.2-fpm restart && /etc/init.d/apache2 restart && /etc/init.d/nginx restart

    0
    Comment actions Permalink
  • Avatar
    Anna Morozyuk

    Hello @Lethalmiko,

    Thank you for the feedback! Other users may find this solution useful as well.

    0
    Comment actions Permalink
  • Avatar
    Mario

    Hi, 

    Working with PHP7.3 only, do we need to install the plesk-php56-devel plesk-php70-devel plesk-php71-devel plesk-php72-devel?

    Also, I just copied and pasted the entire line, if answer to first question is no, can I simply 'yum remove plesk-php56-devel plesk-php70-devel plesk-php71-devel plesk-php72-devel' ?

    Thanks!

    0
    Comment actions Permalink
  • Avatar
    Maxim Krasikov

    Hello @Mario !

    Since you use only PHP 7.3, you don't need to install plesk-php56-devel, plesk-php70-devel, plesk-php71-devel, and plesk-php72-devel packages.

    You may remove them using the following steps:

    1. List installed packages:
    # rpm -qa | grep devel | grep php
    plesk-php73-devel-7.3.5-1centos.7.190506.1021.x86_64
    plesk-php72-devel-7.2.18-1centos.7.190506.1021.x86_64
    plesk-php71-devel-7.1.29-1centos.7.190506.1021.x86_64
    plesk-php56-devel-5.6.40-centos7.19011112.x86_64


    2. Remove packages without dependensies one by one, for example:
    # rpm -evh --nodeps plesk-php56-devel
    # rpm -evh --nodeps plesk-php71-devel
    # rpm -evh --nodeps plesk-php72-devel

    0
    Comment actions Permalink
  • Avatar
    Marcel Aulenbacher

    Hi! I am having issues on Ubuntu 14.04 Trusty with Plesk Onyx
    Version 17.8.11 Update #53

    I have different PHP Versions active on the server:
    5.5.9 which is solely needed by plesk in case I understand that right
    7.1 and 7.2

    I want to get memcached installed on the 7.1 and 7.2, yet I am using those PHP versions for the applications we are running.

    I get the following error following precisely the explanations given here:

    "/opt/plesk/php/7.1/bin$ sudo pecl install memcached
    pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.5.9-1ubuntu4.29
    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"

    Installed memcached version is the latest release 1.5.1

    I am complying with each and any step given in the help section but there is no way to achieve it.

    Help would be much appreciated and thanks in advance!

    0
    Comment actions Permalink
  • Avatar
    Maxim Krasikov (Edited )

    Hello @Marcel Aulenbacher!

    As I can see from the output provided, the command was executed under system PHP 5.5.9 but not under PHP 7.1.
    # /opt/plesk/php/7.1/bin$ sudo pecl install memcached

    Please install memcached using the commands provided in the instruction above in section "Memcached installation" for PHP 7.x.

    0
    Comment actions Permalink
  • Avatar
    Marcel Aulenbacher

    Dear @Maxim Krasikow.

    Thank you for your reply. Using the root user php -v turns out to reply:

    PHP 7.1.29 (cli) (built: May 6 2019 11:09:56) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.1, Copyright (c) 2002-2018, by ionCube Ltd.
    with Zend OPcache v7.1.29, Copyright (c) 1999-2018, by Zend Technologies

    Could you please let me know what I have to do to execute the command under PHP 7.x?

    0
    Comment actions Permalink
  • Avatar
    Nikita Nikushkin

    Hi @Marcel Aulenbacher,

    Please, run one of these commands to install the extension to the required Plesk PHP 7.X version:

    /opt/plesk/php/7.0/bin/pecl install memcached

    OR

    /opt/plesk/php/7.1/bin/pecl install memcached

    OR

    /opt/plesk/php/7.2/bin/pecl install memcached

    OR

    /opt/plesk/php/7.3/bin/pecl install memcached
    0
    Comment actions Permalink
  • Avatar
    Marcel Aulenbacher (Edited )

    Hi @Nikita Nikushkin!

    Thank you for your input. As before mentioned and explained in my original post, this is exactly what I am doing with the root user. As furthermore described this results in the documented problems.

    The problem, as stated, is that apparantly the server tries to use PHP in the 5.6.9 version, even the root user is set to use PHP 7.1 for the execution of the commands.

    Regards!

    0
    Comment actions Permalink
  • Avatar
    Nikita Nikushkin

    Hi @Marcel Aulenbacher,

    This error:

    "/opt/plesk/php/7.1/bin$ sudo pecl install memcached
    pecl/memcached requires PHP (version >= 7.0.0), installed version is 5.5.9-1ubuntu4.29
    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"

    Installed memcached version is the latest release 1.5.1

    is most probably occurs because sudoers run pecl under the system PHP

    I see that "php -v" returned the following:

    PHP 7.1.29 (cli) (built: May 6 2019 11:09:56) ( NTS )

    However, it returns the information for the Plesk PHP 7.1, not for the system one, for some reason

    I suggest repeat these steps:

    1. Login as a root user
    2. Run this command (without sudo):

    /opt/plesk/php/7.0/bin/pecl install memcached

    If the issue still occurs I suggest creating a request to the Support Department for further issue investigation:

    How to submit a request to Plesk support?

    0
    Comment actions Permalink
  • Avatar
    Remigio Ruberto

    On my ubuntu 18.04 LTS I've this issue:

    root@100asa:~# service php72-fpm restart
    Failed to restart php72-fpm.service: Unit php72-fpm.service not found.

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov

    Hi @Remigio, there was a typo in command, it should have a dot "." in the service name, try that way:

    service php7.2-fpm restart

    0
    Comment actions Permalink
  • Avatar
    Christian te Kock

    Hi, i get 

    /opt/plesk/php/7.2/bin/pecl install memcached
    WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
    pecl/memcached can optionally use PHP extension "igbinary" (version >= 2.0)
    pecl/memcached can optionally use PHP extension "msgpack" (version >= 2.0)
    Could not download from "https://pecl.php.net/get/memcached-3.1.4.tgz", cannot download "pecl/memcached" (Connection to `ssl://pecl.php.net:443' failed: )
    Error: cannot download "pecl/memcached"
    Download failed
    install failed

    when i follow this tutorial.

    pecl channel-update pecl.php.net

    gives a "command not found"

    can anyone help? thx.

     

    0
    Comment actions Permalink
  • Avatar
    Anzhelika Khapaknysh

    Hi @Christian te Kock,

    "Connection to `ssl://pecl.php.net:443' failed" looks like an intermittent issue. 
    As far as I see, pecl.php.net  works just fine now.

    0
    Comment actions Permalink
  • Avatar
    Thomas Hellwig

    Hi there,

    thank you for the manual! I installed memcached successful.

    It is working for PHP 7.1, 7.2 and 7.3.

     

    How can i add PHP 7.4 support?

    This way?:

    # yum install plesk-php74-devel

    and then follow step 2:

    # /opt/plesk/php/7.4/bin/pecl install memcached

     

    Thank you in advance!

     

    Thomas

    0
    Comment actions Permalink
  • Avatar
    Alexey Lapshin (Edited )

    Hello @Thomas Hellwig

    Yes, you are right. 

    Please also add the information about extension to the required location:

    # echo "extension=memcached.so" > /opt/plesk/php/7.4/etc/php.d/memcached.ini

    0
    Comment actions Permalink
  • Avatar
    Thomas Hellwig

    Hi Alexey,

    so I have to do these steps if I want to install memcached for php7.4 AND already followed the guide above:

    yum install plesk-php74-devel
    /opt/plesk/php/7.4/bin/pecl install memcached
    echo "extension=memcached.so" > /opt/plesk/php/7.4/etc/php.d/memcached.ini

    Is this correct :)?

    Thank you again!

    0
    Comment actions Permalink
  • Avatar
    Francisco Garcia

    Hi Thomas Hellwig,

    Correct!

    But remember also to re-read the PHP handlers and restart the webserver after adding the extension in the .ini (step 2 > PHP 7.x > steps 4 and 5) :)

    0
    Comment actions Permalink
  • Avatar
    El fadili bouchta

    Hello

     

    How to disable memecached on some directories 

     

    Regards

    0
    Comment actions Permalink
  • Avatar
    Bulat Tsydenov

    Hi El fadili bouchta,

    This article describes only the steps how to install/uninstall the extension. If you need the specifics of how to use it for your needs, I would recommend you checking the official documentation at https://www.php.net/memcached

    You can also ask this question on their page on gihub: https://github.com/memcached/memcached/issues.

    0
    Comment actions Permalink
  • Avatar
    Kevin Johnson

    I followed these instructions successfully until I got to the last step:

    plesk bin php_handler --reread

    the error I get back is:

    [root@server ~]# plesk bin php_handler --list
    The service node must be a web server node.
    exit status 1

    I read that going into Plesk and clicking "refresh components" fixed this issue but when I got in there, 

    ALL items in the list show "The component was not installed" (including nginx, apache, webmail, PHP, literally the entire list)

    All virtual hosts are stuck on an older version of PHP run as CGI, the NPM options have disappeared.

    0
    Comment actions Permalink
  • Avatar
    Yulia Plokhotnikova

    Hi @Kevin Johnson,

    If you did not try to click Refresh Components, please give it a try, as it may change 'not installed' status of all components to a correct one. If this does not solve the issue,consider submitting a support request to Plesk directly or to a reseller, depending on where the license was purchased.

    0
    Comment actions Permalink
  • Avatar
    Kevin Johnson

    hi Yulia Plokhotnikova, it literally says in the first sentence that I DID do that.

     

    0
    Comment actions Permalink
  • Avatar
    Yulia Plokhotnikova

    @Kevin Johnson,

    The error you got was not reported previously to Plesk, so investigation is required. Plesk submit a support request to Plesk directly or to a reseller, depending on where the license was purchased.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request