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 redisThis installs Redis and the DirectAdmin integration. Then add the PHP extension for each PHP version in use:
./build set_php redis yes && ./build php_redisSee CustomBuild for more on PHP builds.
Enable Redis for users
- Enable the Redis feature in user packages (as admin or reseller) where your version offers it.
- 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
- Install an object cache plugin such as Redis Object Cache.
- Add the socket settings to
wp-config.php, for exampledefine('WP_REDIS_SCHEME', 'unix');anddefine('WP_REDIS_PATH', '/home/user/.redis/redis.sock');. - 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
maxmemoryand an eviction policy in the Redis config template.
