Install Memcached on Fedora 24/23, CentOS/RHEL 7.2/6.8/5.11

Memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load. Memcached is a very useful also in other cases, than only dynamic web applications.

This guide explains howto install Memcached 1.4.15/1.4.17 stable version of distributed memory object caching system on Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12 and CentOS / Red Hat (RHEL) 7.2/6.8/5.11. Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12, CentOS 7/6 and Red Hat (RHEL) 7/6 has Memcached on default repos, so extra repositories is not needed.

1. Install Memcached 1.4.15/1.4.17 on Fedora 24/23/22, CentOS/Red Hat (RHEL) 7.2/6.8/5.11

1.1 Install Remi repository (not needed on Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12 and CentOS/RHEL 7/6):

1.2 Install Memcached package

Fedora 24/23/22

Fedora 21/20/19, CentOS/Red Hat (RHEL) 7/6.8

CentOS/Red Hat (RHEL) 5.11

1.3 Configure memcached

Most important value to configure is CACHESIZE, which is cache size on Megabytes. Example Following configuration use 512 Mb memory for Memcached. Edit file /etc/sysconfig/memcached.

1.4 Start Memcached

Fedora 24/23/22/21/20/19 and CentOS/RHEL 7.2

CentOS/RHEL 6.8/5.11

1.5 Check that Memcached is Running and Working

Everything working nice. Then it’s time to test memcache example with some web application.

2. Open Memcached Port (11211) on Iptables Firewall (If the Memcached will also be used other local servers)

2.1 CentOS/Red Hat (RHEL) 6.8/5.11

Edit /etc/sysconfig/iptables file:

Add following INPUT line:

Restart Iptables Firewall:

2.2 Fedora 24/23/22/21/20 and CentOS/Red Hat (RHEL) 7.2

List Your Active Firewalld Zones:

Example output:

Add New Rule to Firewalld:

You might have active zone like public, FedoraWorkstation, FedoraServer.

Restart firewalld.service:

2.3 Test remote connection:

3. Install Memcache and/or Memcached PHP Module on Fedora, CentOS and Red Hat (RHEL)

More information about Memcache Module.
More information about Memcached Module.

3.1 Install Memcache Module and PHP

3.2 Install Memcached Module and PHP

3.3 Restart Web server

Share this post


  1. dude !!! fantastic work man…
    you save my time :)

  2. i am not get any package, first installation successful, but next command say … no package with php-pecl-memcache availabel … what i do ?

    • Hi Anurag,

      Could you post output of following commands:

  3. Did the following on Centos 6.4 (also APC installed):
    yum install memcached
    chkconfig memcached on
    service memcached start

    I have checked that Memcached is Running and Working. This seems to be ok.

    But now what? Is it ready to do its job? Do I have to configure anything else? Or is it just eating my RAM without doing anything use full (yet)?

    • Hi Karel,

      Sounds okay, but could you tell how much is your memory limit and how much is it using RAM without doing anything?

  4. Hi JR, do we need memcached in nginx+php-fpm environment setup?

    • Hi Woody,

      Memcached is not required in nginx+php-fpm setup. You can use memcached with php or even with nginx, but it’s not needed if you don’t want to use it.

  5. Hi JR, How about Varnish Cache? Unable to search any tutorial about Varnish Cache in your webpage, guess it is a good tool to implement it in apache or nginx website?

    • Hi Woody,

      I actually have one draft post, about installing Varnish Cache. Varnish is excellent choice, but many times it’s little bit overkill (and it took a while to get it how very powerful VCL configuration language works) and I have seen people using it totally wrong places, Varnish is excellent if you serve lot of static content. I mean really lot, several thousands hits per second. And yes many users can say that it’s very useful also with small sites, but normally small sites doesn’t have enough resources run Varnish Cache as it should be.

      Many times using Nginx as reverse proxy is very good and much lighter choice. I have used Varnish with this site, but nowadays I prefer Nginx as page cache with conditional passing/purging and CloudFlare service, they have done awesome job and cache nicely all static content. Content delivery works really nice all over the world and it saves lot of bandwidth which is normally expensive.

  6. Thank you very much JR.
    Hope to learn more from you in nginx.. :)

  7. I get this error.

    Fatal error: Class ‘Memcache’ not found in /opt/lampp/htdocs/memcache/memcache_test.php on line 3

    But I’ve installed Memcached correctly and the php modules memcache and memcached.

    P.S. I’m using a xampp(for linux), running on a Fedora 17.

  8. BY the way,can you tell me how to install WALN with rtl8188eus chip driver on CenntOS 7.1 kernel 3.10.0


Submit a Comment

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