In this video tutorial I will show you how to install and configure Memcached module. Similar to Redis, which I did a tutorial in my last video, is an object level caching mechanism that will cache your websites database queries in memory. Enabling this will prevent your application from hitting the database for the same requests and as a result will speed up dynamic websites. This is different from CDN services and
I explain the difference between CDN and Object/Dynamic caching in my previous video so check that out if you’re interested in understanding the differences. So without further ado lets’ check Memcached.
keep in mind I am using Bitnami WordPress blueprint in AWS lightsail for this tutorial. If you have a different setup of LAMP/Wordpress, some of these commands will be slightly different. I will try to link to some documentation that may help you in case your setup is different.
Also for these steps you will need your own VM or full access to your server instance via SSH. If you have shared hosting this is not for you; however your hosting provider may already have all these configurations done for you so you might just have to perform the WordPress steps. Check with your hosting provider. If they don’t have this and are not willing to enable it for you then its’ time to switch hosting providers. AWS Lightsail is great platform to migrate to from a shared hosting environment.
- If setting up new server:
sudo apt update -y
sudo apt upgrade -y
- Install Memcached on bitnami blueprint
apt install memcached
sudo service memcached start
- Install PHP memcached extension
sudo pecl install memcached
- Enable the extension in PHP.ini
sudo vi /opt/bitnami/php/etc/php.ini
- uncomment (remove semicolon) on line ;extension=memcached.so
- Restart (bitnami blueprint)
sudo /opt/bitnami/ctlscript.sh restart
- Check if memcached is enabled
php -i | grep "memcached support"
- Modify wp-config.php
- Add line
- Add line
- Install and Activate W3 Total Cache Plugin
- Configure Plugin to use Memcached