Questions? We're happy to help

How do I use Redis with Magento?

Redis Caching boosts your Magento installation. This way you and your customers can enjoy an even faster webshop.

Important

The PHP module redis must be activated before using Redis Caching with PHP. Read how to activate this module. Also, a Redis database must be created through My Account on our website. The databases are distinguished by the port number. Therefore, database '0' must always be used.

Magento 2.x

Step 1. Log in to cPanel.

Step 2. Under 'File', click 'File Manager'.

Step 3. Navigate to the folder where Magento is installed. Then go to app / etc, right click on the 'env.php' file and then click 'Edit Code'.

Step 4. Scroll to the bottom of the file until you see the last ')'. Here you can paste the following code:

'cache' => array(
    'frontend' => array(
        'default' => array(
            'backend' => 'Cm_Cache_Backend_Redis',
            'backend_options' => array(
                'server' => 'redis.totaalholding.nl',
                'port' => 'YOUR REDIS PORT',
                'password' => 'YOUR REDIS PASSWORD'
            )
        ),
        'page_cache' => array(
            'backend' => 'Cm_Cache_Backend_Redis',
            'backend_options' => array(
                'server' => 'redis.totaalholding.nl',
                'port' => 'YOUR REDIS PORT',
                'password' => 'YOUR REDIS PASSWORD',
                'compress_data' => '0'
            )
        )
    )
),

Example:

You replace 'YOUR REDIS PORT' and 'YOUR REDIS PASSWORD' with the port and password of your Redis database.

Step 5. Click 'Save changes' to save the file. Redis is now activated for Magento 2.x.

Magento 1.8.x and 1.9.x

Step 1. Log in to cPanel.

Step 2. Under 'File', click 'File Manager'.

Step 3. Navigate to the folder where Magento is installed. Then go to app/etc/modules, right click on the file 'Cm_RedisSession.xml' and then 'Code Edit'.

Step 4. Change false to true, click 'Save changes,' then click 'Close.'

Step 5. Click 'one level up' to go to the parent folder, right-click on the file 'local.xml' and then 'Code Edit'.

Step 6. Search for <global> and paste the following code:

<cache>
    <backend>Cm_Cache_Backend_Redis</backend>
    <backend_options>
        <server>redis.totaalholding.nl</server>
        <port>YOUR REDIS PORT</port>
        <persistent>sess-db0</persistent>
        <database>0</database>
        <password>YOUR REDIS PASSWORD</password>
        <force_standalone>0</force_standalone>
        <connect_retries>1</connect_retries>
        <read_timeout>10</read_timeout>
        <automatic_cleaning_factor>0</automatic_cleaning_factor>
        <compress_data>1</compress_data>
        <compress_tags>1</compress_tags>
        <compress_threshold>20480</compress_threshold>
        <compression_lib>gzip</compression_lib>
        <use_lua>0</use_lua>
    </backend_options>
</cache>

Example:

You replace 'YOUR REDIS PORT' and 'YOUR REDIS PASSWORD' with the port and password of your Redis database.

Step 7. Click 'Save changes' to save the file. Redis is now activated for Magento.

 

This knowledgebase article was last updated on: 22 March 2018

Did this article help you?

Status

Ga naar onze statuspagina voor een overzicht van recente storingen en onderhoud.

Opening hours

Maandag — vrijdag 9:00 — 17:00