Use Memcache in Magento2 in Ubuntu
Here are 2 steps for you know How to use Memcache in Magento 2 in Ubuntu:
- Step 1: To install and configure Memcached on Ubuntu
- Step 2: To configure Magento to use Memcache
Step 1 :To install and configure memcached on Ubuntu
1.As a user with root privileges, enter the following command:
apt-get -y update apt-get -y install php5-memcache memcached
2.Change the memcached configuration setting for CACHESIZE and -l:
- Open /etc/memcached.conf in a text editor.
- Locate the -m parameter and change its value to at least 1GB
- Locate the -l parameter and change its value to 127.0.0.1 or localhost
- Save your changes to memcached.conf and exit the text editor.
- Restart memcached.
- service memcached restart
3.Restart your web server: service apache2 restart
Step 2: To configure Magento to use memcache
1.Open <your Magento install dir>/app/etc/env.php
2.Locate the following:
'session' => array ( 'save' => 'files', ), Change it as follows: 'session' => array ( 'save' => 'memcache', 'save_path' => 'tcp://<memcache ip or host>:<memcache port>' ),
To verify memcached works with Magento:
- Delete the contents of the following directories under your Magento installation directory:
- rm -rf var/cache/* var/page_cache/* var/session/*
- Go to any page on the storefront.
- Log in to the Magento Admin and browse to several pages.
- If no errors display, congratulations! memcached is working
Following these steps can help you to use Memcache in Magento2 in Magento2.
For more Magento KB, visit Webnexs Magento Knowledge Base.
Leave a Reply