Web Performance

Installing memcache(d) on Plesk in a multi-PHP environment

Posted on .

Installing memcache(d) on Plesk in a multi-PHP environment


Install dependencies & repos EPEL & IUS

yum install epel-release
wget https://centos7.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release*.rpm
yum install make gcc plesk56-devel plesk-php70-devel plesk-php71-devel zlib-devel glibc-devel libmemcached-devel

Make sure to add plesk??-devel for each PHP version you need memcache(d) installed.

Install memcache & memcached for each PHP version

In this example I'm installing for PHP 7.1. Repeat for each PHP version, updating 7.1/71 to the versions you need it.

/opt/plesk/php/7.1/bin/pecl install memcache
/opt/plesk/php/7.1/bin/pecl install memcached
When installing for PHP7+, you may get the following error. If you're not getting this error, proceed to Register modules in PHP
Makefile:193: recipe for target 'memcache.lo' failed
make: *** [memcache.lo] Error 1
ERROR: `make' failed

You can compile an alternative yourself to get around this

Compile & install a non blocking to PHP 7 alternative


cd /root/addons/php/extensions
wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
unzip NON_BLOCKING_IO_php7.zip
cd pecl-memcache-NON_BLOCKING_IO_php7
./configure --enable-memcache --with-php-config=/opt/plesk/php/7.1/bin/php-config
cp /root/addons/php/extensions/pecl-memcache-NON_BLOCKING_IO_php7/modules/memcache.so /opt/plesk/php/7.1/lib64/php/modules


cd /root/addons/php/extensions git clone https://github.com/php-memcached-dev/php-memcached.git cd php-memcached /opt/plesk/php/7.1/bin/phpize ./configure
--disable-memcached-sasl --with-php-config=/opt/plesk/php/7.1/bin/php-config make make install

Register modules in PHP

echo "extension = memcached.so" > /opt/plesk/php/7.1/etc/php.d/memcached.ini
echo "extension = memcache.so" > /opt/plesk/php/7.1/etc/php.d/memcache.ini

Reread Plesk PHP handler & restart php-fpm for the PHP version you just installed.

plesk bin php_handler --reread
systemctl restart plesk-php71-fpm

Repeat this for each PHP version 7.0, 5.6, etc.. Mind the version number on almost each command!

There are no comments.

Leave a Reply

View Comments (0) ...