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:
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
Uninstalling memcached extension
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
-