DirectAdmin

Add Redis or Memcached object caching on DirectAdmin

Install Redis with CustomBuild as a DirectAdmin admin, enable per-user Redis instances, add the PHP extension, and connect WordPress or other apps for faster pages.

AdvancedDirectAdmin admin2 min read

Object caching stores the results of expensive database queries in memory, so dynamic sites like WordPress, WooCommerce or Magento answer much faster under load. DirectAdmin supports Redis through CustomBuild and can give each user their own private Redis instance.

Before you start

  • Admin-level access and root SSH to the DirectAdmin server.
  • Spare RAM – each Redis instance uses memory proportional to what is cached.

Install Redis (admin)

cd /usr/local/directadmin/custombuild && ./build set redis yes && ./build redis

This installs Redis and the DirectAdmin integration. Then add the PHP extension for each PHP version in use:

./build set_php redis yes && ./build php_redis

See CustomBuild for more on PHP builds.

Enable Redis for users

  1. Enable the Redis feature in user packages (as admin or reseller) where your version offers it.
  2. Users then see Advanced Features → Redis and can click Enable. DirectAdmin starts a Redis instance running as that user, listening on a Unix socket in their home directory (for example /home/user/.redis/redis.sock).

Per-user instances are isolated: one user cannot read another's cache – much safer than a single shared Redis on port 6379.

Connect WordPress

  1. Install an object cache plugin such as Redis Object Cache.
  2. Add the socket settings to wp-config.php, for example define('WP_REDIS_SCHEME', 'unix'); and define('WP_REDIS_PATH', '/home/user/.redis/redis.sock');.
  3. Enable the object cache in the plugin settings and check its status shows Connected.

Other applications (Laravel, Magento) configure the same socket path in their cache settings.

Memcached

Memcached is a simpler alternative without persistence. It can be installed from OS packages plus the PHP memcached extension via CustomBuild. Redis is usually preferred today because of per-user support in DirectAdmin and richer data types.

Measure the gain

Compare page generation time or time to first byte before and after on logged-in and uncached pages. Object caching helps most where page caching cannot be used – admin areas, carts and member pages.

Troubleshooting

  • Plugin cannot connect: wrong socket path or Redis not enabled for the user; check the path shown in DirectAdmin.
  • Class Redis not found: the PHP redis extension is not built for the site's PHP version.
  • Memory pressure: set maxmemory and an eviction policy in the Redis config template.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.