Installing Redis Cache on CentOS 7/6

Redis caching system that stores data in RAM is similar Memcached. Format not only supports cache keys / values ​​as good as Memcached that Redis also supports many data structures such as hash, list, set, sorted sets, and string.

Redis fully supports similar functions but manipulation Memcached retrieve and load data very quickly, than memcached.

In this article, I will guide you installing Redis on CentOS and Redis configuration instructions for work on WordPress and Magento.

To Redis can work with Magento, we will need to install Redis server with PHP extension can PhpRedis to connect with Redis.

1. Add EPEL repo, remi

 CentOS 7 ## ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

CentOS 6 ## ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

2. Install Redis and PhpRedis extension

 PHP 5.6 ## ##
yum --enablerepo = remi, remi-php56 install php-pecl-Redis Redis
php-fpm service restart

PHP 5.5 ## ##
yum --enablerepo = remi, remi-php55 install php-pecl-Redis Redis
php-fpm service restart

– Running Redis and automatically start at boot

 chkconfig Redis on
Redis service start

1. Check back Redis server

 Redis-cli ping

If the result of PONG is ok

2. Check back PhpRedis extension

 php -m | grep Redis

The results of Redis is ok

3. Redis shell tools

Default Redis installed with a tool comment is Redis-cli

After booting Redis, you can use a command like:

  • FLUSHALL – clear all databases
  • SELECT # – select the database under Index #
  • FLUSHDB – hiện selected empty database
  • KEYS * – list all keys from hiện selected

See the complete list of command here .

4. Application management and tracking Redis

Once installed, you can use PHPRedMin to manage Redis with intuitive interface on the web. Download here .

compression is done, you rename the folder phpredmin-master to phpredmin such then up to the server. Access to the management interface using the link: http://domain.com/phpredmin/public/

The login username / password default is admin / admin . To edit the file you open /phpredmin/config.dist.php up and correct corresponding in paragraph auth

 'auth' => array (
  'Username' => 'admin',
  'Password' => password_hash ( 'admin', PASSWORD_DEFAULT)
),

If left step login, you delete a few lines on the go is.

PHPRedMin used rewritten, so you need to reconfigure the new rules work.

– With Apache:

  Alias ​​ / phpredmin / var / www / phpredmin / public


    AllowOverride  All

   
      # Apache 2.4 
     
        Require  ip localhost
        Require  local
   
   
      # Apache 2.2 
      Order   Deny   Allow 
      Deny  from All
      Allow  from 127.0.0.1
      Allow  from :: 1
   

– With Nginx:

 location / phpredmin / public / 
   $ uri $ uri try_files / /phpredmin/public/index.php;

After the installation is completed and activated Redis service, you just need to install additional plugins W3 Total Cache and then activate selected Redis configuration page is finished.

With Magento, Redis supports different versions. In case your Magento version does not support Redis backend cache or session (or both), you can use to install extensions.

Magento CE> = 1.7.0.0 and <1.8.0.0

  • Session storage – does not support
  • -no Cache backend support, after installing the class name is Cm_Cache_Backend_Redis

Magento CE> = 1.8.0.0

  • Session storage – support
  • -backed cache backend, after installing the class name is Mage_Cache_Backend_Redis

Magento EE> = 1.13.0.0 and <1.13.1.0

  • Session storage – does not support
  • Cache backend – support, after installing the class name is Mage_Cache_Backend_Redis

Magento EE> = 1.13.1.0

Session storage – support
Cache backend – support, after installing the class name is Mage_Cache_Backend_Redis

Using Redis as cache backend

Redis To activate, simply edit the file app / etc / local.xml add the following to the corresponding position to use database 0

            CACHE_BACKEND_CLASS_NAME  
          
             127.0.0.1  
             6379 
              
             0 
             
             0  
             1  
             10  
             0  
             1  
             1  
             20480  
             gzip  
          

Rather CACHE_BACKEND_CLASS_NAME by class name as mentioned above.

Redis Once activated, you can delete the entire contents of the folder var / cache . Redis To check if there really are active or not, run the tool Redis-cli then use the following commands with the database 0

 SELECT 0
KEYS *

Redis works very effectively, particularly with large websites with data, mainly the SELECT query, you can not ignore this stuff.

Installing Redis Cache on CentOS 7/6
5 (100%) 10 vote