Get Free Linux Server Security, Performance & Troubleshooting Tips

How to install PHP-Memcache on PHP 7.x using cPanel

How to install PHP-Memcache on PHP 7.x using cPanel
5 (100%) 3 votes

After reading, investigating and tried lot of ways to install PHP-Pecl Memcache module in PHP 7.x I realized that there are many known issues with pecl’s provided memcache module in PHP 7+. But I found a way to install PHP-Memcache on PHP 7.x, keep reading.

Luckly, the guys at uploaded to Github an alternative version of PHP-Memcache that compiles and works fine in PHP 7.x versions. You can review all the changes at their Github proyect:

Step by step: install PHP-Memcache on PHP 7

Download and extract the file

cd /usr/local/src;
wget; unzip; cd pecl-memcache-NON_BLOCKING_IO_php7;

Configure, compile and install

/opt/cpanel/ea-php71/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php71/root/usr/bin/php-config && make;

Copy and enable the modile inside cPanel PHP 7.1 php.ini files

cp -av modules/ /opt/cpanel/ea-php71/root/usr/lib64/php/modules/;
echo ';enable memcache pecl module php7' > /opt/cpanel/ea-php71/root/etc/php.d/40-memcached.ini; echo '' >> /opt/cpanel/ea-php71/root/etc/php.d/40-memcached.ini;

Restart Apache to apply changes:


After doing so, you will notice that the module is properly being reported by PHP 7.1:

[]php -v
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 7.1.0 (cli) (built: Jan 4 2017 15:09:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.1.0, Copyright (c) 1999-2016, by Zend Technologies

Now run the following command to see if PHP-Memcache is loaded in your PHP server:

php -i | grep memcache -i

This should be the expected output:

[]php -i | grep memcache -i
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 32768 => 32768
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 2 => 2
Registered save handlers => files user memcache

That’s it. Now you should have PHP-Memcache working fine with PHP 7.x versions on cPanel / EA4 based servers. If you know other ways to install PHP-Memcache on PHP 7.x, please let us know so we can add your method to this tutorial.



  1. Hello,
    after following this guide, php is showing the memcache extension but when I try to login I get : PHP WARNING: session_start(): Failed to read session data: memcache

    Any help?

      1. Hey Esteban,
        yes the deamon is started and listening on port 11211.

        root 26650 0.0 0.0 364424 4424 ? Ssl Apr04 3:28 /usr/local/memcached/bin/memcached -d -p 11211 -u root -m 1024 -c 2048 -P /var/run/

        I’ve another instance of php5.6.6 and that is pointing to memcached for sessions, and it is working.

        I tried installing php7.0.13 and now, I don’t get the error anymore on the apache logs, but the login still does not work.

          1. Hi Esteban, yes the path is writable as the php5 is writing to it.
            I tried installing memcached extension and it worked using ‘’ but I would like to continue using memcache for failover etc. Any other suggestion?

            This is my php.ini now :
            session.save_handler = memcache
            session.save_path = ‘tcp://’
            memcache.lock_timeout = 60

Leave a Reply

Your email address will not be published. Required fields are marked *