Performance Optimization

Redis and Memcached Setup

By the Domain India teamPublished 6 min read
Knowledge base article
Contents (7 sections)

Redis and Memcached keep frequently used data in memory, so your application can skip repeated database queries. Neither is available on Domain India shared hosting: to use them, you install and run them yourself on a VPS. This guide explains what to use on shared hosting instead, and how to set up Redis or Memcached safely on your own server.

Key takeaways

Redis and Memcached are not available on Domain India shared hosting (cPanel, DirectAdmin or Webuzo), and the App Platform has no Redis add-on. On shared hosting, use what is already there: OPcache, page caching and the cPanel caching proxy. If your app needs Redis or Memcached, run it on a Domain India VPS, which is self-managed: you install, secure and update it.

1. Redis vs Memcached

FeatureRedisMemcached
Data typesStrings, lists, sets, hashes, sorted sets, streamsStrings only
PersistenceOptional (RDB snapshots, AOF)None; memory only
ExtrasPub/sub, atomic counters, locks, queuesSimple key-value cache
Typical useWordPress object cache, Laravel cache, sessions and queuesSimple object or session cache
Recommended forMost new applicationsExisting setups that already use it

For a new PHP or WordPress site, Redis (or Valkey, its open-source fork) is the usual choice.

2. What you can use on Domain India shared hosting

Shared hosting has no Redis or Memcached server, and the PHP extensions for them are not loaded, so enabling them from the panel is not possible. You still get useful caching:

  • OPcache keeps compiled PHP in memory. It is enabled on our cPanel servers, and on our DirectAdmin servers for every PHP version except PHP 8.3. See PHP OPcache guide.
  • Page caching plugins for WordPress, such as WP Super Cache or W3 Total Cache with disk caching, serve stored pages without running PHP for each visitor.
  • The cPanel caching proxy: our cPanel servers run nginx in front of Apache, and it can keep serving a stored copy of a page for up to 120 minutes. Add ?t=1 to a URL to check a change.
  • Laravel and other frameworks: use the database or file cache driver.

If the site is still slow, work through My website is slow before you move to a bigger setup.

No Redis on shared hosting or the App Platform

Redis and Memcached are not offered on any shared hosting plan, and the App Platform has no Redis add-on (each plan includes PostgreSQL). If you need Redis, the route is your own VPS.

3. Install Redis on your VPS

A Domain India VPS is self-managed: you have root access and look after the software yourself.

bash
# Ubuntu / Debian
sudo apt update
sudo apt install -y redis-server
sudo systemctl enable --now redis-server

# AlmaLinux / Rocky 9
sudo dnf install -y redis
sudo systemctl enable --now redis

# AlmaLinux / Rocky 10 ship Valkey, a compatible fork
sudo dnf install -y valkey
sudo systemctl enable --now valkey

Check that it answers:

bash
redis-cli ping      # or: valkey-cli ping
# PONG

4. Secure and size Redis

Edit the config file: /etc/redis/redis.conf on Ubuntu and AlmaLinux 9, or /etc/valkey/valkey.conf for Valkey.

code
# Listen on this server only
bind 127.0.0.1 -::1
protected-mode yes

# Require a password
requirepass your-strong-password

# Cap memory and evict the least recently used keys when full
maxmemory 256mb
maxmemory-policy allkeys-lru

Restart the service after any change. Never open port 6379 in your firewall: an exposed Redis is one of the most common ways servers get taken over.

5. Install Memcached on your VPS (if you need it)

bash
# Ubuntu / Debian
sudo apt install -y memcached
# AlmaLinux / Rocky
sudo dnf install -y memcached
sudo systemctl enable --now memcached

Make sure it listens on 127.0.0.1 only and has UDP disabled (-l 127.0.0.1 -U 0 in /etc/memcached.conf on Ubuntu, or OPTIONS in /etc/sysconfig/memcached on AlmaLinux). Memcached has no password by default, so it must never be reachable from the internet.

For PHP, install the matching extension from your OS packages (for example php-redis or php-memcached on Ubuntu), or with PECL. Note that memcached and memcache are different PHP extensions; most applications want memcached.

6. Connect WordPress and Laravel

  1. Install the plugin.
    In WordPress, add and activate the Redis Object Cache plugin.
  2. Add the connection to wp-config.php,
    above the "That's all, stop editing" line: define('WP_REDIS_HOST', '127.0.0.1');, define('WP_REDIS_PORT', 6379);, define('WP_REDIS_PASSWORD', 'your-strong-password'); and a unique define('WP_REDIS_PREFIX', 'site1_'); for each site.
  3. Enable the object cache.
    Go to Settings › Redis, click Enable Object Cache, and check that the status shows Connected.

For Laravel, set CACHE_STORE=redis (Laravel 11 and later; older versions use CACHE_DRIVER) and the REDIS_* values in .env. Tags, locks and stampede prevention are covered in Laravel + Redis cache.

7. Monitor and troubleshoot

  • Hit rate: redis-cli INFO stats shows keyspace_hits and keyspace_misses. For Memcached, send stats to port 11211 and compare get_hits with get_misses.
  • Memory: redis-cli INFO memory. If memory keeps growing, set maxmemory and an eviction policy.
  • Cannot connect: check the service with systemctl status redis (or redis-server, valkey), the port, and that the password matches in the config and your app.
  • WordPress cache not working: check that wp-content/object-cache.php exists and that only one caching plugin handles the object cache.

For more on caching layers, see Server-side caching.

Can I enable Redis or Memcached on Domain India shared hosting?

No. Redis and Memcached are not available on Domain India shared hosting (cPanel, DirectAdmin or Webuzo), and the PHP extensions for them are not loaded. Use OPcache, a page caching plugin or your framework's database or file cache on shared hosting, or run Redis on a VPS.

Does the App Platform offer Redis?

No. The App Platform has no Redis add-on; each plan includes a PostgreSQL database. For Redis, use a VPS.

Do you install Redis on a VPS for me?

A Domain India VPS is self-managed, so you install and maintain Redis yourself with the commands in this guide.

Redis or Memcached for a new site?

Redis, in most cases. It has richer data types, optional persistence and wide plugin support. Memcached is fine if your application already uses it.

Is it safe to open the Redis port so another server can connect?

Not directly. Keep Redis bound to 127.0.0.1 and reach it from other servers through a private network or an SSH tunnel, with a password set.

Ready to run Redis? Choose a Domain India VPS. For help with caching on your hosting account, open a support ticket.

Need Redis or Memcached?

A self-managed VPS gives you root access to install Redis, Valkey or Memcached and tune them for your application.

View VPS plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Redis and Memcached Setup: Shared Hosting vs VPS