Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Caching Server»How To Install Memcached on CentOS/RHEL 7/6/5

    How To Install Memcached on CentOS/RHEL 7/6/5

    By RahulJune 5, 20192 Mins Read

    Memcached is a distributed memory object caching system which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enabled speed by caching objects in memory. Read more about memcache.

    Advertisement

    Read Article:
    Set Up phpMemcachedAdmin on Linux


    This article will help you to install Memcached and PHP Memcache extension on CentOS/RHEL 7/6/5 systems.

    Install Memcached Server

    First we will install Memcached server on our system. Use following command to install memcached using yum package manager.

    yum install memcached
    

    Now start Memcached service using following commands.

    For CentOS/RHEL 7
    systemctl enable memcached
    systemctl start memcached
    
    For CentOS/RHEL 6/5
    service memcached start
    chkconfig memcached on
    

    Install PHP with Memcache PHP Extension

    Now we have installed Memcached server on our system. But to use Memcached service using php scripts we need to install Memcache php extension. So first install php and other required php modules and then use PECL to install PHP Memcache extension using following commands.

    commentyum groupinstall "Development tools"
    yum install zlib zlib-devel
    yum install php php-devel php-pear
    

    After installing php-pear package install PECL extension using command below.

    pecl install memcache
    

    Now we need to enable memcache module in php. Add following line at end of php.ini file.

    echo "extension=memcache.so" >> /etc/php.d/memcache.ini
    

    Restart Apache service to enable extension

    For CentOS/RHEL 7
    systemctl restart httpd
    
    For CentOS/RHEL 6/5
    service httpd restart
    

    Verify Memcache Setup

    Use following command to check and verify that memcached service is running fine.

    echo "stats settings" | nc localhost 11211
    
    STAT maxbytes 67108864
    STAT maxconns 1024
    STAT tcpport 11211
    STAT udpport 11211
    STAT inter 127.0.0.1
    STAT verbosity 0
    STAT oldest 0
    STAT evictions on
    STAT domain_socket NULL
    STAT umask 700
    STAT growth_factor 1.25
    STAT chunk_size 48
    STAT num_threads 4
    STAT num_threads_per_udp 4
    STAT stat_key_prefix :
    STAT detail_enabled no
    STAT reqs_per_event 20
    STAT cas_enabled yes
    STAT tcp_backlog 1024
    STAT binding_protocol auto-negotiate
    STAT auth_enabled_sasl no
    STAT item_size_max 1048576
    STAT maxconns_fast no
    STAT hashpower_init 0
    STAT slab_reassign no
    STAT slab_automove 0
    END
    
    

    Now check if memcache php extension is enabled and working properly. Create a info.php file using following code

    <?php
      phpinfo();
    ?>
    

    Now access info.php on web interface and search for Memcache, You will get result like below.

    php-memcache

    memcache memcached PHP
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing PHP on Pop!_OS

    How to Install PHP 8.x on Pop!_OS

    Managing Dependencies with Composer: A Beginner’s Guide

    How to Change Redis Max Memory

    View 4 Comments

    4 Comments

    1. TheoYu on February 6, 2018 4:52 am

      Thanks Nice post

      Reply
    2. Ken on November 22, 2016 1:48 pm

      Thank you 🙂

      Reply
    3. Webslesson on February 9, 2016 6:37 am

      Nice Post.

      Reply
    4. BIKRAM THAPA on August 12, 2015 1:46 pm

      Now we need to enable memcache module in php. Add following line at end of php.ini file.
      # echo “extension=memcache.so” >> /etc/php.d/memcache.ini

      Are you sure this command will update the php.ini file.?

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    • sleep Command in Linux with Examples
    • 20 Basic Linux Commands for the Beginners (Recommended)
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.