How to implement Memcached in Magento v.2?

Follow this tutorial to easily implement Memcached in Magento 2:

  1. First make sure you Activate Memcached caching in your control panel. You will need those IP and port number
  2. Check the PHP version. PHP 5.6 or earlier would work. PHP 7 will not work with this tutorial.
  3. Edit /app/etc/env.php:
    1. Using ssh, go to the root of your Magento installation. Under the app/etc/ directory locate “env.php”. This file you need to edit.
    2. Locate this code string
      'session' =>
          array (
          'save' => 'files',
      ),
      
    3. Edit that to match the following:
      'session' =>
         array (
            'save' => 'memcache',
            'save_path' => 'tcp://250.250.250.1:1000'
      ),
      

    In this line you have to replace the IP address and port number with the Memcached details that you get in your control panel.

  4. Test if it works. Go to the root of Magento installation and clear the contents of the cache:
    rm -rf var/cache/* var/page_cache/* var/session/*
    
  5. Make a final test by loading your site in your browser. If your website shows up, the configuration is correct.
Updated on 27 August 2021

Was this article helpful?

Related Articles

Comments

Comments are closed.