Docs Home Return to Homepage
Get Started Login

How to Speed Up WordPress with Redis Object Cache in cPanel

Last updated Changelog

On this page

Redis keeps frequently used data in memory, so WordPress doesn’t have to ask the database for the same things on every page view. NameCrane’s cPanel hosting includes your own private Redis, with a start/stop switch right in cPanel. There are three parts: start Redis, switch on PHP’s redis extension, and tell WordPress to use it.

Part 1: Start Redis

  1. Log in to cPanel. In the Databases section, click Redis Object Cache.

    The cPanel Databases section with Redis Object Cache highlighted

  2. The Status shows Stopped. Click Start Redis Object Cache.

    The Redis Object Cache page showing Status: Stopped and the Start button highlighted

  3. The status changes to Running. Note the Socket Path, which is how apps connect to your Redis. It’s /home/yourusername/.redis/redis.sock, with your own cPanel username.

    Status: Running and the socket path /home/cranedemo/.redis/redis.sock highlighted

Part 2: Switch on PHP’s redis extension

  1. Go back to the cPanel home page and open Select PHP Version (in Software). On the Extensions tab, tick redis. cPanel saves it straight away, and also turns on igbinary and msgpack, which it needs.

    The PHP Selector Extensions tab with redis ticked

Part 3: Connect WordPress

  1. Open your site’s wp-config.php in File Manager (it’s in public_html for your main domain) and click Edit. Just above the line /* That's all, stop editing! Happy publishing. */, add these two lines, using your own cPanel username, then click Save Changes:

    php
    define( 'WP_REDIS_SCHEME', 'unix' );
    define( 'WP_REDIS_PATH', '/home/yourusername/.redis/redis.sock' );
    

    The wp-config.php file in File Manager’s editor with the two WP_REDIS lines highlighted

    Warning: wp-config.php also contains your database password. Don’t share screenshots of the whole file.

  2. Log in to WordPress and go to Plugins › Add New Plugin. Search for Redis Object Cache (by Till Krüss) and click Install Now.

    The WordPress plugin search with Redis Object Cache and its Install Now button highlighted

  3. Click Activate.

    The Activate button highlighted on the Redis Object Cache plugin

  4. Go to Settings › Redis and click Enable Object Cache.

    The Redis Object Cache settings page with Enable Object Cache highlighted

  5. The Status now shows Connected, and Client shows PhpRedis. Your site is now using Redis.

    Status: Connected and Client: PhpRedis highlighted on the plugin’s Overview tab

Tip: If you change plugins or content and something looks out of date, click Flush Cache on the same page.

Troubleshooting

Problem What to do
The plugin says Not connected Check Redis shows Running in cPanel, and that WP_REDIS_PATH matches your Socket Path exactly, including your username.
Client shows Predis instead of PhpRedis It still works, just a little slower. Tick redis under Select PHP Version › Extensions for the faster client.
My site shows an error after editing wp-config.php Check you copied both lines exactly, including the quotes and semicolons, and that they’re above the “stop editing” line.
Redis stopped Click Start Redis Object Cache again. You can also stop it there if you no longer need it.

Snagged on something? Contact support and we’ll get you sorted.

Snagged on something?

Our sysadmins answer tickets around the clock.