Applicable to:
- Plesk for Linux
Question
How to install/uninstall memcached PHP extension for Plesk PHP handlers?
Answer
Note: Installation of additional PHP extension is not covered by Plesk support.
-
Connect to a Plesk server via SSH.
-
Prepare the environment:
-
on CentOS/RHEL-based distributions:
# wget -q -O - http://www.atomicorp.com/installers/atomic | sh && yum install make memcached gcc libmemcached-devel zlib-devel plesk-php*-devel
-
on Debian/Ubuntu-based distributions:
# apt install memcached autoconf automake gcc libmemcached-dev libhashkit-dev pkg-config plesk-php*-dev zlib1g-dev
-
- Install the memcached PHP extension:
Note: In the example below, we are installing memcached for PHP 7.4. For other PHP versions, replace 7.4 in the commands below with a required PHP version.
# /opt/plesk/php/7.4/bin/pecl install memcached
During the installation, additional parameters will be requested. Hit "Enter" for each option to install memcached with default options or specify required values:
CONFIG_TEXT: libmemcached directory [no] :
zlib directory [no] :
use system fastlz [no] :
enable igbinary serializer [no] :
enable msgpack serializer [no] :
enable json serializer [no] :
enable server protocol [no] :
enable sasl [yes] :
enable sessions [yes] : -
Register extension in PHP configuration file:
# echo "extension=memcached.so" > /opt/plesk/php/7.4/etc/php.d/memcached.ini
-
Update PHP handlers information:
# plesk bin php_handler --reread
-
Restart the PHP-FPM service:
# service plesk-php74-fpm restart
-
Restart the Apache service:
-
on CentOS/RHEL-based distributions:
# service httpd restart
-
on Debian/Ubuntu-based distributions:
# service apache2 restart
-
-
Verify that the memcached module has been installed:
# /opt/plesk/php/7.4/bin/php -m | grep memcached
memcached
Note: In the example below, we are uninstalling PHP 7.4. For other PHP versions, replace 7.4 in the commands below with a required PHP version.
- Connect to a Plesk server via SSH.
-
Remove the memcached configuration file:
# rm /opt/plesk/php/7.4/etc/php.d/memcached.ini
-
Uninstall the extension:
# /opt/plesk/php/7.4/bin/pecl uninstall memcached
-
Update PHP handlers information:
# plesk bin php_handler --reread
-
Restart the PHP-FPM service:
# service plesk-php74-fpm restart
-
Restart the Apache service:
-
on CentOS/RHEL-based distributions:
# service httpd restart
-
on Debian/Ubuntu-based distributions:
# service apache2 restart
-
Comments
60 comments
Hi @Marcel Aulenbacher,
This error:
is most probably occurs because sudoers run pecl under the system PHP
I see that "php -v" returned the following:
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):
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?
@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
On Plesk Onyx Web Pro Edition 17.5.3 + CentOS 7 I got this error:
/opt/plesk/php/7.1/bin/pecl install memcached
shtool at '/tmp/memcached/build/shtool' does not exist or is not executable.
Make sure that the file exists and is executable and then rerun this script.
ERROR: `phpize' failed
Was solved by doing this first:
mount -o remount,exec /tmp
After that it installed properly with:
/opt/plesk/php/7.1/bin/pecl install memcached
See: https://support.plesk.com/hc/en-us/articles/115001406994-Error-while-using-pecl-install-shtool-at-tmp-does-not-exist-or-is-not-executable
Hello @Lethalmiko,
Thank you for the feedback! Other users may find this solution useful as well.
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.
tried to follow the instruction for PHP 7.1 with Plesk 17.5.3 Update #38 on Ubuntu 14.04.5 but it stops with
configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check.
Tried with this flag but doesn't help. Any ideas?
Because I lost a day trying all the options, here are the steps that worked for me:
Plesk 18.0.38, Centos 8, PHP 7.3
------------------------------------------------------------------------------
install memcached, libmemcached, plesk php devel and compilers.
install php pecl memcached:
to this question, answer with "no --disable-memcached-sasl"
*normally path is /usr/include/libmemcached and memcached.h is there but it would complain it cannot find it !
when asked to enable sasl (default yes), ANSWER no !
watch for errors at the end of this install, if all good, it will say:
add "extension=memcached.so" to php.ini
went to "Tools and settings > php settings > php x.x" and add to php.ini:
create a phpinfo(); page, it should display a memcached area with details
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.
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.
@Gabriel De León, Hi!
The article has been modified. Please check the instructions.
Hi @Graham, glad to hear that this helped =)
@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.
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.
Hello @William,
As I have checked on the test server with CentOS 6, when PHP 5.6 is installed, this file exists on the file system.
Please, make sure that PHP 5.6 is installed in Plesk. If it is installed, try reinstalling it, it should resolve the issue.
Hi Alexey,
so I have to do these steps if I want to install memcached for php7.4 AND already followed the guide above:
Is this correct :)?
Thank you again!
Hello @Lobbe Maxime
Thank you for bringing our attention to this.
The article was outdated - there was no plesk-php73-devel in the preparation stage for RHEL-based OS.
I have updated the article.
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.
Hi @Marcel Aulenbacher,
Please, run one of these commands to install the extension to the required Plesk PHP 7.X version:
OR
OR
OR
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
@Miha, there is a possibility that package update removed the whole PHP folder taking the memcached. Please vote for adding it to Plesk packages https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/6594919-memcached-support
@Florian Thiel
Hello!
The libmemcached package for Ubuntu 14.04 does not support SASL authentication.
Which error is displayed with the option -disable-memcached-sasl?
Package "plesk-php70-dev" or "plesk-php71-dev" or "plesk-php72-dev" not available for Debian 9 "stretch". Any chance on adding them?
Hello
How to disable memecached on some directories
Regards
Have installed it (on php 5.4 for centos) but can't start the server. Can't find the folder where it's installed. Where is it?
Hello,
Thanks for this tutorial.
On debian 9, how to configure Memcached parameters (like memory) ?
I found nothing in /etc
Hi all,
since when this notice is here: "Note: Memcached extension is only available/supported up to PHP 7.1"?
I'm using it for PHP 7.4 since last year and this time there was no such notice?
Thank you!
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!
@Peter Westerlund
The article is about installing php extension for memcached, it is supposed that memcached server already installed. I think you just need to install memcached daemon.
# yum install memcached
or
# apt-get install memcached
You may also look at the blog post:
https://www.plesk.com/blog/product-technology/reduce-server-load-with-memcached/
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
Hello @Remy,
Glad to hear that the solution helped!
Please sign in to leave a comment.