Everyone should consider improving their WordPress website performance. When running a WordPress blog, your #1 priority should be making sure your server is optimized and using cache plugins to speed up the website.
One of the many caching programs to use is Redis. Redis is an open source in-memory database which can be used to store / cache data. It’s a great solution to implement and can be done easily with WordPress.
This brief tutorial shows students and new users how to setup WordPress with Redis caching on Ubuntu 17.04 | 17.10
To get started with enable Redis with WordPress support, please continue below:
The first thing is to have a working WordPress site… If you don’t have WordPress installed, then search our site for help installing WordPress..
We have covered WordPress installation with both Apache2 and Nginx support on this site….
Step 1: Install the Latest Redis Server
After installing WordPress, run the commands below to install the latest version of Redis…
The version of Redis server that comes with Ubuntu by default isn’t the latest… To install the latest version you will have to add the PPA below and install from there…
To do that, run the commands below:
sudo apt-get install software-properties-common
Once that package is installed, run the commands below to add the PPA that contains the latest version of Redis…
sudo add-apt-repository ppa:chris-lea/redis-server
After adding the repository, run the command below to install Redis…
sudo apt-get update sudo apt-get install redis-server php-redis
Verify that you have version 4 of Redis installed with the following command:
You should see Redis virsion installed on your system….
Step 2: Allocate Memory to Redis and Setup an Eviction Policy
Now that Redis is installed, run the commands below to open its configuration file…
sudo nano /etc/redis/redis.conf
Then uncomment the lines below to allow memory and an eviction policy… You’ll have to scroll through the lines to find these… Then set then up as shown below:
maxmemory 256mb maxmemory-policy allkeys-lfu
Save the file and exit…
When you’re done run the commands below restart Redis and PHP… If you’re running Apache2, then just restart Apache2 and Redis server…
sudo systemctl restart redis-server sudo systemctl restart php7.2-fpm
Step 3: Configure WordPress wp-config.php file
After the above steps run the commands below to open WordPress wp-config.php file in your WordPress root directory…
sudo nano /var/www/html/wordpress/wp-config.php
Then add these lines just below WordPress unique Keys and Salts section…
define( 'WP_CACHE_KEY_SALT', 'example.com' ); define( 'WP_CACHE', true );
After that, save the file and exit..
Step 4: Install a Redis Object Cache Plugin
The final step is to install WordPress Redis Object Cache Plugin… To do that navigate to the plugin page and install in WordPress…
After installing, activate and enable the plugin… When you’re done, go to the plugin settings page and if everything is configured correctly, you should see something similar to the image below:
That should do it!
Your WordPress setup should now use Redis object caching to help speed up your site…
You may also like the post below: