HOWTOlabs redis, memcache
Configuration tips

redis
rickatech 2016-09 (edit)

Elsewhere

As of 2016 Redis has become the defacto memory cache for supporting all manner of web services, essentially replacing venerable memcache.

# yum install redis

# yum install php-pecl-redis

# systemctl status redis   

Elsewhere

Most web servers default to storing web session state directly on local file system.  Redis can be used to store sessions in memory instead.  PHP is a popular service session framework, and it can be configured to detext and use redis service instead of local file store for sessions state.

# yum install redis

# yum install  php56w-pecl-redis

# diff /etc/httpd/conf.d/php.conf

23,25c23,28
< php_value session.save_handler "files"
< php_value session.save_path    "/var/lib/php/session"
< php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"
---
> php_value session.save_handler "redis"
> php_value session.save_path    "tcp://127.0.0.1:6379"
> php_value soap.wsdl_cache_dir  "tcp://127.0.0.1:6379"

# systemctl restart redis

# systemctl restart httpd 

$ cat .../session.php 

  <?php  //simple session counter for testing
  session_start();
  $count = isset($_SESSION['count']) ? $_SESSION['count'] : 1;
  echo $count;
  $_SESSION['count'] = ++$count;

$ redis-cli -h localhost

  > keys *

    1) "PHPREDIS_SESSION:fepl2i5rm53gn58qq8ii7tbi07"  
memcache
fredness 2011 (edit)

Elsewhere

Installing with yum ...

Check for reasonably latest release for your architecture.

# rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/...

# wget http://packages.sw.be/perl-Net-SSLeay/perl-Net-SSLeay-...rpm

# rpm -ivh perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm

  ...

# yum install memcached

  ... 

  Installed:
    memcached.i386 0:1.4.5-1.el5.rf

  Dependency Installed:
    compat-libevent-11a.i386 0:3.2.1-1.el5.rf
    perl-AnyEvent.noarch 0:5.240-1.el5.rf
    perl-EV.i386 0:3.9-1.el5.rf
    perl-Guard.i386 0:1.021-1.el5.rf
    perl-JSON.noarch 0:2.50-1.el5.rf
    perl-JSON-XS.i386 0:2.30-1.el5.rf
    perl-TermReadKey.i386 0:2.30-3.el5.rf
    perl-YAML.noarch 0:0.72-1.el5.rf
    perl-common-sense.i386 0:3.0-1.el5.rf

  Complete!

# memcached -h

  memcached 1.4.5
 
  ...

# yum install php-pecl-memcache

  ...

# service httpd restart

  Stopping httpd: [  OK  ]
  Starting httpd: [  OK  ]

# service memcached status

  memcached is stopped

# service memcached start

  Starting Distributed memory caching (memcached): [  OK  ]

# ps -e | grep memcached

  2076 ? 00:00:00 memcached