Azure Cloud

How to use Redis Cache with WordPress on Azure : Part 7

Are you looking to create your very own Scalable optimized WordPress Site/blog using Azure MySQL, Azure Storage and Azure CDN, then this post series is for you?

I have divided the series into below parts:

  1. Getting Azure Subscription, Creating App Service Plan and WordPress Web Service using My SQL In App
  2. Connecting Word Press website with WordPress.com and Installing and configuring Jet Pack
  3. Creating Azure Database for MySQL and exporting the Data from My SQL In App to Azure Database for MySQL Server, Handling Security and Optimizing with persistent connection
  4. Creating Azure Storage Account and configuring WordPress to use Azure Storage to store media files and Optimizing with persistent connection.
  5. Configuring Custom domain, SSL Certificates.
  6. Configuring CDN, configuring back up scheduling in azure and Auto Scaling
  7. How to use REDIS CACHE with WORDPRESS on Azure
  8. How to install application insights in WordPress on Azure

If you are not following along please check the previous part 1 first.

Now days it is very important to deliver your content as fast as you can deliver, in the world of performance Redis Cache have significantly gained the traction when it comes to quick response in milliseconds.

Since we are using Azure, it is very simple to use Azure Redis Cache with WordPress on azure. It start with creating an instance on your azure subscription and make sure to create it on same datacenter in which your App Service resides.

Go to Azure Portal click on add button, search for Redis Cache, fill the form and choose your Pricing tier according to your needs and click on create. It could take some time it to provision.

Figure 1 Create Azure Redis Cache for WordPress

Now go to your WordPress Dashboard and search for Redis Cache, you will find a Plugin with name Redis Object Cache, click on Install Now to install it. Once you are done, we need to install the plugin to our Azure App Service.

Figure 2 Install Redis Object Cache

Now go to below link and get the appropriate version of the plugin, in my case my PHP version is 7.1 you can see your by going to App Service | Application Settings | PHP Version

https://pecl.php.net/package/redis

Figure 3 get the plugin for Redis Object Cache

Now extract and Go to KUDU, App Service | Development Tools | Advanced Tool | GO, then click on Debug console | CMD and then click on site | siteextensions, you could see the path in CMD windows as D:homesitesiteextensions. Drag and drop the php_redis.dll here

Figure 4 Upload php_redis.dll to site extensions

Now create a folder in D:homesite as “ini” and create new file in it as “extensions.ini” and put this text in there and save

; Enable Extensions

extension=d:homesitesiteextensionsphp_redis.dll

Figure 5 Create ini folder with extensions.ini file

Figure 6 edit extensions.ini file

Now activate the Redis plugin from WordPress and after that go to WordPress | Settings | Redis and click diagnostics link. Right now, we have not modified wp-config.php file to put the required configuration so it will show Redis: Not Found. Let us do that now.

Figure 7 Redis Object Cache Diagnostics

Go back to KUDU, and navigate to d:homesitewwwroot and then edit wp-config.php and copy paste below code and do not forget to mention configuration highlighted as blod.

// Redis Cache plugin configuration

define(‘WP_REDIS_SCHEME’, ‘tcp’);

define(‘WP_REDIS_HOST’, ‘<redishost>‘);

define(‘WP_REDIS_PORT’, ‘6379’);

define(‘WP_REDIS_DATABASE’, ‘0’);

define(‘WP_REDIS_PASSWORD’, ‘<yourpass>‘);

define(‘WP_CACHE_KEY_SALT’, ‘<prefix>’);

Figure 8 Edit Wp-config.php

You can get the hostname and password from Redis Cache Overview as shown below. For password click on keys and use primary key.

Figure 9 Redis Cache Dashboard

Now click on Enable Object Cache, and wait for some time to enable it, after some time it will load the configuration and it will show you the status connected. If for some reason you it do not show connected then click on show diagnostics and enable disable object cache a few times.

Figure 10 Redis Cache is enabled.

Congratulations, you have successfully configured the Redis Cache with WordPress on Azure.

coming up next How to install application insights in WordPress on Azure

5 thoughts on “How to use Redis Cache with WordPress on Azure : Part 7”

Leave a Reply