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 make
Note: For Debian 12 an additional package is needed:
apt install libssl-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
9 comments
Tried using these instructions and got an error when installing the PHP extension.
Ubuntu 22.04.3 LTS
Plesk Obsidian 18.0.54
Hello Jason,
It looks like some libraries are missing on the server.
You may either re-run the command below:
Or refer to the steps from the 'Installation errors and troubleshooting' section of the following article: https://support.plesk.com/hc/en-us/articles/12377140315671.
Nothing appears to be missing.
İ have a challenge for you. Memcached doesn't work anymore. I get always empty string. Memcached was working over a year without any problem... And now. Baaammm.. Any idea?
These instruction will be failed if you want to change "igbinary => yes" on Centos 7.9. Could you please check it again?
@Pega Olymp igbinary is an optional component. If it is not installed on your server and you try to use it, the installation of the PHP memcached extension will fail. That is an expected behavior. If you want to use igbinary, you first need to install it.
Anyway as a not Plesk expert, I would like to explain the my question's answer very basicly (because this support instruction has to be detailed by an expert).
If you want to add igbinary or json or etc. support your php client, you have to install their devel rpm's. This will give you needed .h file but in an incorrect location, you have to copy it to correct location and try to install that support your php client again.
# /opt/plesk/php/7.4/bin/pecl uninstall memcached
PHP Fatal error: Uncaught Error: Cannot use object of type PEAR_Error as array in /opt/plesk/php/7.4/share/pear/PEAR/Dependency2.php:1036
Stack trace:
#0 /opt/plesk/php/7.4/share/pear/PEAR/Installer.php(1669): PEAR_Dependency2->validatePackageUninstall()
#1 /opt/plesk/php/7.4/share/pear/PEAR/Command/Install.php(997): PEAR_Installer->uninstall()
#2 /opt/plesk/php/7.4/share/pear/PEAR/Command/Common.php(270): PEAR_Command_Install->doUninstall()
#3 /opt/plesk/php/7.4/share/pear/pearcmd.php(310): PEAR_Command_Common->run()
#4 /opt/plesk/php/7.4/share/pear/peclcmd.php(32): require_once('/opt/plesk/php/...')
#5 {main}
thrown in /opt/plesk/php/7.4/share/pear/PEAR/Dependency2.php on line 1036
Pega Olymp As shown in the screenshot: "cannot find config for extension 'memcached'" causes the uninstall to fail. It's also seen in line #4. If the extension is no proper installation, it is expected that an automatic uninstall fails, because it cannot find the expected files.
Please sign in to leave a comment.