Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Caching Server»How To Install Memcached on CentOS/RHEL 7/6/5

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

    RahulBy RahulFebruary 7, 20152 Mins ReadUpdated:June 5, 2019

    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.


    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
    Previous ArticleError installing mysql2 Gem on Linux
    Next Article How to Install Memcached on Ubuntu 18.04 & 16.04 LTS

    Related Posts

    How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04

    Updated:May 9, 20223 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    How To Install and Use PHP Composer on Debian 11

    Updated:February 16, 20224 Mins Read

    How To Install PHP (8.1, 7.4 & 5.6) on Debian 11

    Updated:February 16, 20224 Mins Read

    How to Enable Debug Mode in Laravel

    Updated:May 28, 20211 Min Read

    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

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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