memcachedpeclphp-7centos6.5

Memcache extension with PHP 7 on CentOS fails to install


I'm trying to upgrade a fairly large PHP 5.3 code base to PHP 7. It's hosted on CentOS 6.5, so I want to keep it on that OS. I'm currently doing it on a virgin Vagrant box - I've installed PHP 7 successfully, and all the modules except for Memcache.

As root, when I run pecl install memcache it tries to install v2.2.7 but I get a long list of errors and warnings from make. At the end is:

make: *** [memcache.lo] Error 1
ERROR: `make' failed

According to GoPHP7 it should work, Memcache should work with PHP 7 - it says "php7 port on github". There is indeed a Memcache PHP 7 port on GitHub. When I look at the Memcache page on Pecl page, it shows that I should be installing v3.0.8, but this in beta (and has been since 2013).

So I try to run pecl install memcache-3.0.8 and it still fails, with the same error as above:

make: *** [memcache.lo] Error 1
ERROR: `make' failed

So is it possible to get the Memcache extension working with PHP 7 on CentOS 6.5?


Solution

  • If you haven't solved this yet, I have a solution that worked for me. I'm on CentOS 7.x but it should still work for you, and anyone else wanting to use pecl-memcache with PHP 7 (not pecl-memcached as that's a completely different package).

    As you have already discovered, you must use the Memcache PHP 7 port on GitHub for this.

    Login to your shell and perform the following:

     1. wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip
     2. unzip NON_BLOCKING_IO_php7.zip
     3. cd pecl-memcache-NON_BLOCKING_IO_php7
     4. /opt/cpanel/ea-php70/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config && make
     5. cp modules/memcache.so /opt/cpanel/ea-php70/root/usr/lib64/php/modules/
     6. echo 'extension=memcache.so' >/opt/cpanel/ea-php70/root/etc/php.d/memcached.ini
     7. service httpd restart
    

    Some notes for the above:

    I hope that helps!