Improve the performance of your dynamic website with Memcached Cache on AWS Lightsail

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.

Video:

Steps:

  1. If setting up new server:
    1. sudo apt update -y
    2. sudo apt upgrade -y
  2. Install Memcached on bitnami blueprint
    1. apt install memcached
    2. sudo service memcached start
  3. Install PHP memcached extension
    1. sudo pecl install memcached
  4. Enable the extension in PHP.ini
    1. sudo vi /opt/bitnami/php/etc/php.ini
    2. uncomment (remove semicolon) on line ;extension=memcached.so
  5. Restart (bitnami blueprint)
    1. sudo /opt/bitnami/ctlscript.sh restart
  6. Check if memcached is enabled
    1. php -i | grep "memcached support"
  7. Modify wp-config.php
    1. Add line define('WP_CACHE',true);
  8. Install and Activate W3 Total Cache Plugin
  9. Configure Plugin to use Memcached

Links:

memcached – a distributed memory object caching system

https://www.mysterydata.com/configure-and-speedup-wordpress-with-memcached-on-php-7/

https://www.plesk.com/blog/product-technology/reduce-server-load-with-memcached/

How To Install Memcached on Ubuntu Server And Configure WordPress (thecustomizewindows.com)

https://www.cloudways.com/blog/wordpress-memcached-server-tutorial/#5