Tag Archives: Redis

Magento 2 Enable Redis

Install Redis.

And then edit app/etc/env.php to configure Magento to use Redis for session storage, default and page caching.

'session' =>
array (
'save' => 'redis',
'redis' =>
array (
'host' => '',
'port' => '6379',
'password' => '',
'timeout' => '2.5',
'persistent_identifier' => '',
'database' => '2',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '6',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '0',
'min_lifetime' => '60',
'max_lifetime' => '2592000'
'cache' =>
'frontend' =>
'default' =>
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' =>
'server' => '',
'database' => '0',
'port' => '6379'
'page_cache' =>
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' =>
'server' => '',
'port' => '6379',
'database' => '1',
'compress_data' => '0'

Install Redis CentOS 7 Linux

Run the following commands to install redis

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make test
make install

Create a directory where to store your Redis config files and your data:

mkdir /etc/redis
mkdir /var/redis

Copy the init script that you’ll find in the Redis distribution under the utils directory into /etc/init.d. We suggest calling it with the name of the port where you are running this instance of Redis. For example:

cp utils/redis_init_script /etc/init.d/redis_6379

Copy the template configuration file you’ll find in the root directory of the Redis distribution into /etc/redis/ using the port number as name, for instance:

cp redis.conf /etc/redis/6379.conf

Create a directory inside /var/redis that will work as data and working directory for this Redis instance

mkdir /var/redis/6379

Edit the configuration file, making sure to perform the following changes:

vi /etc/redis/6379.conf

Set daemonize to yes (by default it is set to no).
Set the pidfile to /var/run/redis_6379.pid (modify the port if needed).
Change the port accordingly. In our example it is not needed as the default port is already 6379.
Set your preferred loglevel.
Set the logfile to /var/log/redis_6379.log
Set the dir to /var/redis/6379 (very important step!)

Finally add the new Redis init script to all the default runlevels using the following command

chkconfig --add redis_6379

Start Redis instance.

/etc/init.d/redis_6379 start

Check if Redis is working

redis-cli ping


Redis is a data structure server. It is open-source, networked, in-memory, and stores keys with optional durability.

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.