Install the Memcached PHP libraries on Plesk Linux
Memcached is a free and powerful object caching system that you can install to improve the performance of your website. Memcached will only work if you install the daemon, install the PHP libraries and configure your PHP application properly.
The PHP libraries for Memcached are installed over the command line. You'll need to be logged in as the root user to run these commands.
- Enable administrator access on your Gen 3 or Gen 4 server if you haven't already done so.
- Connect to my server with SSH (Secure Shell).
- Switch to the root user.
- Install the required dependencies
- CentOS users:
yum -y install gcc glibc-devel libmemcached-devel zlib-devel plesk-php*-devel
- AlmaLinux users:
yum groupinstall "Development Tools"
- Ubuntu users:
apt install autoconf automake gcc libmemcached-dev libhashkit-dev pkg-config plesk-php*-dev zlib1g-dev
- CentOS users:
- Install the PHP PECL library for the desired version of PHP. You'll need to do this for each version of PHP you're using.
/opt/plesk/php/7.4/bin/pecl install memcached
You'll be prompted several times while the software installs. Unless you have a specific need, press "enter" to accept the default value in each case.
Note: In some situations, you may see an error like this:
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
If this happens, configure PHP to use a different temporary directory and re-run the command.
mkdir /root/tmp && /opt/plesk/php/7.4/bin/pear config-set temp_dir /root/tmp /opt/plesk/php/7.4/bin/pecl install memcached -
Register the module in PHP.
echo "extension=memcached.so" > /opt/plesk/php/7.4/etc/php.d/memcached.ini
-
Update Plesk's PHP handler.
plesk bin php_handler --reread
-
Finally, restart Apache and PHP-FPM.
systemctl restart httpd systemctl restart plesk-php74-fpm
- Ubuntu users:
systemctl restart apache2 systemctl restart plesk-php74-fpm
- Ubuntu users:
Related Steps
- Return to Install the Memcached daemon.
- Move on to configure your website to utilize Memcached.
More info
- Our server experts can perform these steps for a fee. For more information about our Expert Services, please visit our Expert Service menu.