WordPress and Redis Integration

Redis is the world’s fastest in-memory database. It provides cloud and on-prem solutions for caching, vector search, and NoSQL databases that seamlessly fit into any tech stack—making it simple for digital customers to build, scale, and deploy the fast apps our world runs on.

About – Redis

If you’ve seen this alert on your WordPress website:

You can resolve it by installing Redis on your Linux server and integrating it with your WordPress installation by following these steps!

  1. Install Redis on Linux:
    • Most major Linux distributions provide packages for Redis. We’ll focus on Ubuntu/Debian here.
    • Open a terminal and run the following commands:

      # Install prerequisites (if needed)
      sudo apt install lsb-release curl gpg

      # Add the Redis repository to the apt index
      curl -fsSL [^1^][1] | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] [^2^][2] $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

      # Update the package index
      sudo apt-get update

      # Install Redis
      sudo apt-get install redis
  2. Install the Redis PHP Extension:
    • To communicate with Redis from PHP (which WordPress uses), you’ll need the PHP extension.
    • Install it using the following command:
      • sudo apt-get install php-redis
  3. Configure the Redis WordPress Plugin:
    • Log in to your WordPress admin dashboard.
    • Go to “Plugins”“Add New”.
    • Search for “Redis Object Cache” and click “Install Now”.
    • Once installation is complete, click “Activate” to enable the plugin.
    • Go to “Settings”“Redis” to configure the plugin.
  4. Ensure it starts on Startup
    • When you first install Redis, it may work fine but when you restart the server you’ll notice it’s not running. To make sure it’s running on startup type the following:
      • sudo systemctl enable redis-server
  5. Test that Redis is Running
    • To test that Redis is running, type:
      • redis-cli ping
    • If you get a message that says, Could not connect to Redis at 127.0.0.1:6379: Connection refused it means that Redis is not running and you need to Start it. If it’s running, it’ll say Pong
    • You can also type: sudo systemctl status redis-server which should return something like:
      Redis Screenshot after testing sudo systemctl status redis-server
  6. To Start Redis on your server:
    • Type:
      • sudo systemctl start redis-server
  7. Test and Monitor:
    • Visit your WordPress site and ensure that the Redis cache is working.
    • Monitor your site’s performance and load times.

Remember to adjust any additional settings based on your specific server environment. Redis caching will significantly boost your WordPress site’s performance!

Leave a Comment

Your email address will not be published. Required fields are marked *