Install Memcached on Ubuntu 14.04 /15.04

Memcached is a high-performance, in-memory storing that caches objects for faster website performance. Rather than disk caching, Memcached stores objects in memory which is faster thann disk. It is extremely valuable for caching so as to improve dynamic sites and enabled speed by caching objects in memory.
Memcache

See Also:

  • Install Memcached on CentOS/RHEL 5/6/7
  • Install phpMemcachedAdmin on Linux
  • In this article we will explain how to install Memcached on Ubuntu 12.04, 14.04, 14.10 and 15.04 systems.

    Step #1 Install Memcached

    First we prefer to update all of the packages of your system

    # sudo apt-get update
    

    Now use following command to install memcached on your system.

     
    # sudo apt-get install memcached
    

    Step #2 Memcached Server Configuration

    Memcached configuration file as below:

    # sudo vim /etc/memcached.conf
    

    Note:

  • “-m”: Setting up a memory limits
  • “-l”: Set an IP address to listen on
  • “-c”: Limit the number of simultaneous incoming connections
  • Step #3 Restart Memcached service

    Run below command to restart the memcached service:

    For Ubuntu 12.04/14.04/14.10
    # sudo service memcached restart
    For Ubuntu 15.04
    # sudo systemctl restart memcached
    

    Step #4 Install the Memcached PHP Extension

    Now install PHP Memcached extension and related packages for setup so simple run below command:

    # sudo apt-get install php5 php5-dev php-pear php5-memcached
    # sudo apt-get install libmemcached-dev build-essential
    

    Step #5 Restart Apache2 service

    Run below command to reflect the changes:

    For Ubuntu 12.04/14.04/14.10
    # sudo service apache2 restart
    For Ubuntu 15.04
    # sudo systemctl restart apache2
    

    Step #6 Verify Memcache Setup

    Use following command to verify that memcached service is running fine or not.

    # 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
    

    Step #7 Check Memcache PHP Extension

    Now check Memcache php extension is enabled and working properly.

    # sudo vim /var/www/html/info.php
    
    <?php
    phpinfo();
    ?>
    

    Now access below url to check memcache PHP Extension.

    http://server-ip/info.php
    Or
    http://Hostname/info.php
    

    Install Memcached
    Enjoy it!

    Leave a Reply

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

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    The reCAPTCHA verification period has expired. Please reload the page.