The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Installing memcache and memcached with EasyApache4

Discussion in 'EasyApache' started by cPGeoffS, Aug 25, 2016.

Tags:
  1. cPGeoffS

    cPGeoffS Technical Analyst
    Staff Member

    Joined:
    Dec 11, 2012
    Messages:
    11
    Likes Received:
    5
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    Hello Everyone!

    PHP extensions for Memcache and Memcached are now available in the EasyApache 4 Experimental Repository. Here's the latest comment regarding this change from the memcached-in-easyapache4 feature request:

    Once you have reviewed the instructions and warnings on the Experimental Repository document, you can choose to enable the repo and install the packages via the following commands:

    Code:
    yum install ea4-experimental
    yum install ea-php56-php-memcache
    yum install ea-php56-php-memcached
    Replace "php56" with the version of PHP you want to install the extensions on (e.g. php54, php55, php70).

    To installed the Memcached daemon, run this command:

    Code:
    yum install ea-memcached
    Let us know if you have any questions.

    Thanks!

    Note: The previous workaround instructions are also unsupported, but are provided below for reference:

    The following thread is intended to offer step-by-step instructions to administrators that would like to install the Memcached and Memcache PECL modules on EasyApache 4. I encourage anyone reviewing this thread to vote and add feedback to the following feature request if you'd like to see these options made available as native PHP options in EasyApache 4:

    MemcacheD in EasyApache4

    To start, here's some background information about the packages installed with these instructions:

    libmemcached is an open source C/C++ client library and tools for the memcached server (memcached - a distributed memory object caching system). It has been designed to be light on memory usage, thread safe, and provide full access to server side methods.

    The PECL memcached package is an extension that uses the libmemcached library to provide API for communicating with memcached servers.

    The PECL memcache package is an extension allows you to work with memcached through handy OO and procedural interfaces.

    This guide does not cover installing the Memcached daemon.

    To begin the installation, first install cyrus-sasl-devel and lib-memcached using the following commands:

    Code:
    yum install cyrus-sasl-devel
    mkdir /root/lib-memcached-install
    cd /root/lib-memcached-install
    wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
    tar -xvzf libmemcached-1.0.18.tar.gz
    cd libmemcached-1.0.18
    ./configure
    make && make install

    Next, install the Memcached Pecl Module for each version of PHP active on your system.

    Note: Please see the post here if you are receiving popen() has been disabled for security reasons errors.

    Code:
    mkdir /root/memcached-php54-pecl
    cd /root/memcached-php54-pecl
    /opt/cpanel/ea-php54/root/usr/bin/pecl download https://pecl.php.net/get/memcached-2.2.0.tgz
    tar -xvf memcached-2.2.0.tgz
    cd memcached-2.2.0
    /opt/cpanel/ea-php54/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php54/root/usr/bin/php-config
    make && make install
    echo 'extension=memcached.so' >> /opt/cpanel/ea-php54/root/etc/php.d/memcached.ini

    Code:
    mkdir /root/memcached-php55-pecl
    cd /root/memcached-php55-pecl
    /opt/cpanel/ea-php55/root/usr/bin/pecl download https://pecl.php.net/get/memcached-2.2.0.tgz
    tar -xvf memcached-2.2.0.tgz
    cd memcached-2.2.0
    /opt/cpanel/ea-php55/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php55/root/usr/bin/php-config
    make && make install
    echo 'extension=memcached.so' >> /opt/cpanel/ea-php55/root/etc/php.d/memcached.ini

    Code:
    mkdir /root/memcached-php56-pecl
    cd /root/memcached-php56-pecl
    /opt/cpanel/ea-php56/root/usr/bin/pecl download https://pecl.php.net/get/memcached-2.2.0.tgz
    tar -xvf memcached-2.2.0.tgz
    cd memcached-2.2.0
    /opt/cpanel/ea-php56/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config
    make && make install
    echo 'extension=memcached.so' >> /opt/cpanel/ea-php56/root/etc/php.d/memcached.ini

    Code:
    mkdir /root/memcached-php70-pecl
    cd /root/memcached-php70-pecl
    /opt/cpanel/ea-php70/root/usr/bin/pecl download memcached
    tar -xvf memcached*
    cd memcached*
    /opt/cpanel/ea-php70/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config
    make && make install
    echo 'extension=memcached.so' >> /opt/cpanel/ea-php70/root/etc/php.d/memcached.ini
    

    Code:
    mkdir /root/memcached-php71-pecl
    cd /root/memcached-php71-pecl
    /opt/cpanel/ea-php71/root/usr/bin/pecl download memcached
    tar -xvf memcached*
    cd memcached*
    /opt/cpanel/ea-php71/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php71/root/usr/bin/php-config
    make && make install
    echo 'extension=memcached.so' >> /opt/cpanel/ea-php71/root/etc/php.d/memcached.ini
    

    Then, install the Memcache PECL module for each version of PHP active on your system.
    Note: Please see the post here if you are receiving popen() has been disabled for security reasons errors.

    Code:
    /opt/cpanel/ea-php54/root/usr/bin/pecl install memcache
    echo 'extension=memcache.so' >> /opt/cpanel/ea-php54/root/etc/php.d/memcache.ini

    Code:
    /opt/cpanel/ea-php55/root/usr/bin/pecl install memcache
    echo 'extension=memcache.so' >> /opt/cpanel/ea-php55/root/etc/php.d/memcache.ini

    Code:
    /opt/cpanel/ea-php56/root/usr/bin/pecl install memcache
    echo 'extension=memcache.so' >> /opt/cpanel/ea-php56/root/etc/php.d/memcache.ini

    Code:
    mkdir /root/memcache-php70-pecl
    cd /root/memcache-php70-pecl
    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
    /opt/cpanel/ea-php70/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php70/root/usr/bin/php-config && make
    cp modules/memcache.so /opt/cpanel/ea-php70/root/usr/lib64/php/modules/
    echo 'extension=memcache.so' >/opt/cpanel/ea-php70/root/etc/php.d/memcache.ini
    

    Code:
    mkdir /root/memcache-php71-pecl
    cd /root/memcache-php71-pecl
    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
    /opt/cpanel/ea-php71/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php71/root/usr/bin/php-config && make
    cp modules/memcache.so /opt/cpanel/ea-php71/root/usr/lib64/php/modules/
    echo 'extension=memcache.so' >/opt/cpanel/ea-php71/root/etc/php.d/memcache.ini
    

    Finally, verify each version of PHP active on your system includes the Memcached and Memcache modules:

    Code:
    /opt/cpanel/ea-php54/root/usr/bin/php -m |grep memcache
    /opt/cpanel/ea-php55/root/usr/bin/php -m |grep memcache
    /opt/cpanel/ea-php56/root/usr/bin/php -m |grep memcache
    /opt/cpanel/ea-php70/root/usr/bin/php -m |grep memcache
    /opt/cpanel/ea-php71/root/usr/bin/php -m |grep memcache
    Here's an example of the output you should see:

    Code:
    # /opt/cpanel/ea-php70/root/usr/bin/php -m |grep memcache
    memcache
    memcached
    Let us know if you have any questions about these instructions.

    Thank you.
     
  2. cPMarkF

    cPMarkF *nix Technical Analyst
    Staff Member

    Joined:
    Feb 4, 2013
    Messages:
    10
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    The following post is intended for the previous workaround instructions for the Memcache and Memcached PHP extensions in EasyApache 4 created prior to the existence of the packaged offered in the EA4 Experimental Repo:

    Let's have more fun. Need igbinary support in memcached? If you've done all the steps above, you need to remove the source directory of memcached-2.2.0 and untar the tarball again to get a fresh directory.

    Download and install igbinary from PECL:

    Code:
    wget https://pecl.php.net/get/igbinary-1.2.1.tgz
    tar -vxzf igbinary-1.2.1.tgz
    cd igbinary-1.2.1
    /opt/cpanel/ea-php56/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config
    make && make install
    

    Create your igbinary.ini

    Code:
    echo 'extension=igbinary.so' >> /opt/cpanel/ea-php56/root/etc/php.d/igbinary.ini
    

    Go into your newly re-extracted memached-2.2.0 directory and rebuild memcached, enabling igbinary support (note: if you've already built memcached using the previous steps outlined above in this thread, you do not need to create or echo the module into the memcached.ini again)

    Code:
    cd memcached-2.2.0
    /opt/cpanel/ea-php56/root/usr/bin/phpize
    ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config --enable-memcached-igbinary
    

    During the config.status output, you should see these lines:

    Code:
    checking whether to enable memcached igbinary serializer support... yes
    checking for memcached igbinary support... enabled
    

    If not, make sure you followed the steps above to install igbinary. If so, then:

    Code:
    make && make install
    

    Afterwards, you should see igbinary support not only in PHP, but also for memcached:

    Code:
    [17:21:38 sg root@server ~/memcached-2.2.0]cPs# php -i | grep igbinary
    /opt/cpanel/ea-php56/root/etc/php.d/igbinary.ini,
    igbinary
    igbinary support => enabled
    igbinary version => 1.2.1
    igbinary APC serializer ABI => 0
    igbinary session support => yes
    igbinary.compact_strings => On => On
    igbinary support => yes
    memcached.serializer => igbinary => igbinary
    Registered serializer handlers => php_serialize php php_binary igbinary wddx
    
    Hope this helps!
     
    #2 cPMarkF, Sep 9, 2016
    Last edited by a moderator: Mar 8, 2017
    cPanelMichael likes this.
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    34,845
    Likes Received:
    1,058
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    We've updated this thread to include information about packages available in the EA4 experimental repo, and to update the manual workaround instructions to address some of the common problems reported during the installation process. Some of the previous posts to this thread were removed, with the solutions included in the updated instructions. Let us know if you have any questions.

    Thanks!
     
  4. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    284
    Likes Received:
    3
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
    How to uninstall memcache-php71-pecl (manual install)

    Why EA 4 Using memcached Version 3.0.2? When memcached 3.0.3 stable Version? Do we need uninstall “PHP Pecl” Installer memcached (3.0.3) ?
     
  5. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    582
    Likes Received:
    85
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Thanks for the feedback. This is an experimental module, so it won't receive full attention until we send it through the team and full QA processes. I'll attempt to get these modules update to the latest versions in the next day or so.

    Also, I do believe you will need to uninstall the previous module you had installed, to ensure no conflicts.
     
  6. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    284
    Likes Received:
    3
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
    Then how to uninstall previous modules? I have installed this both modules with this this thread manually installing tutorials.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    34,845
    Likes Received:
    1,058
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You can remove the memcache.so module and memcache.ini/memcached.ini files. For instance, if you installed the Memcache and Memcached PECL modules for PHP 7.1, you'd run the following commands:

    Code:
    rm /opt/cpanel/ea-php71/root/usr/lib64/php/modules/memcache.so
    rm /opt/cpanel/ea-php71/root/etc/php.d/memcache.ini
    rm /opt/cpanel/ea-php71/root/etc/php.d/memcached.ini
    Thank you.
     
  8. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    284
    Likes Received:
    3
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
    Still can not remove Memcache PECL modules for PHP 7.1, I have installed Memcache from this follow the steps listed below.

    Code:
    mkdir /root/memcache-php71-pecl
    cd /root/memcache-php71-pecl
    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
    /opt/cpanel/ea-php71/root/usr/bin/phpize && ./configure --enable-memcache --with-php-config=/opt/cpanel/ea-php71/root/usr/bin/php-config && make
    cp modules/memcache.so /opt/cpanel/ea-php71/root/usr/lib64/php/modules/
    echo 'extension=memcache.so' >/opt/cpanel/ea-php71/root/etc/php.d/memcache.ini
     
  9. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    284
    Likes Received:
    3
    Trophy Points:
    18
    cPanel Access Level:
    Website Owner
    Code:
    [2017-03-23 23:40:27 +0600] info [xml-api]   Installing : ea-php71-php-memcached-3.0.2-1.1.9.cpanel.x86_64             1/2
    [2017-03-23 23:40:27 +0600] info [xml-api]   Installing : ea-php71-php-memcache-3.0.8-1.3.8.cpanel.x86_64              2/2Purging all relevant cached command results
    @cPanelMichael Installed memcache-3.0.8 but still are showing Manual Installation Version 3.0.9-dev


    Screenshot_1.png
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    34,845
    Likes Received:
    1,058
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    That's actually the version provided by the RPM published to the EA4 experimental repo. Internal case EA-6097 is open to address that version number mismatch. I'll update this thread with more information on case EA-6097 once it's available, but keep in mind the RPM is still considered experimental.

    Thank you.
     
  11. fast lane

    fast lane Registered

    Joined:
    May 30, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    After following these instructions I can't find the memcached config file anywhere. Memcached appears to be running but I can't telnet into it (telnet localhost 11211). Help?

    Also, for future reference how would I uninstall memcached (having followed your revised install instructions with the experimental repo).
     
    #11 fast lane, Apr 2, 2017
    Last edited by a moderator: Apr 2, 2017
  12. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    34,845
    Likes Received:
    1,058
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    The daemon itself isn't offered through cPanel, but is generally started with a command such as:

    Code:
    memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
    As far as configuring it, there's a third-party URL that discusses this at:

    Memcache basic configuration

    You'd simply remove the packages with the YUM command:

    Code:
    yum remove ea-php56-php-memcache
    yum remove ea-php56-php-memcached
    Thank you.
     
  13. fahl

    fahl Active Member

    Joined:
    Jul 30, 2008
    Messages:
    29
    Likes Received:
    2
    Trophy Points:
    3
    I have installed as in first post. mem.jpg
    But no memcach.cfg in etc/sysconfig & using
    memcached -d -u nobody -m 1024 127.0.0.1 -p 11211
    i get following error
    -bash: memcached: command not found
    Help needed please
     
  14. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    34,845
    Likes Received:
    1,058
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello @fahl,

    What method did you use to install the Memcached daemon? This is separate to the PHP extensions referenced on this thread, and typically installed with a command such as:

    Code:
    yum install memcached
    Thank you.
     
  15. fahl

    fahl Active Member

    Joined:
    Jul 30, 2008
    Messages:
    29
    Likes Received:
    2
    Trophy Points:
    3
    Getting this error when saving php.ini

    Code:
    API failure: (XID cnefq8) 2 errors occurred: Error #1: The php.ini file contains an invalid line: “Module Settings”. Error #2: The php.ini file contains an invalid line: “echo 'extension=memcache.so'”.
    Placed at bottom of php.ini

    Code:
    ; this value may still be overridden on a per-stream basis via the "capath"
    ; SSL stream context option.
    ;openssl.capath=
    
    ; Local Variables:
    ; tab-width: 4
    
    echo 'extension=memcache.so'
    
    ; End:
    What am i doing wrong please

    Running php70
     
  16. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    34,845
    Likes Received:
    1,058
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    This is the actual command to run as opposed to the entry that should appear in the /opt/cpanel/ea-php70/root/etc/php.d/memcached.ini file. This is the output you should see when running the "cat /opt/cpanel/ea-php70/root/etc/php.d/memcached.ini" command (when using the manual installations instructions):

    Code:
    extension=memcached.so
    Thank you.
     
Loading...

Share This Page