Applies to: CS-Cart & Multi-Vendor on cPanel/AlmaLinux/Rocky/CentOS with LiteSpeed Web Server.
Goal: Use Redis for CS-Cart caching (and optionally sessions) when Redis is installed via the LiteSpeed WHM plugin.
Prerequisites
- Redis server installed and running via WHM → LiteSpeed Web Server → Plugins → Redis (or equivalent install).
- PHP Redis extension enabled for the domain’s PHP version (usually installed with the LiteSpeed Redis tool). If unsure, create a
phpinfo.phpand confirm you see a “redis” section. - CS-Cart file access (cPanel File Manager or SSH) and ability to clear cache.
Step 1 — Verify Redis is running
- In WHM, open LiteSpeed Web Server → Redis and confirm the service status shows Running.
- Optionally check via SSH:
A healthy Redis replies withredis-cli pingPONG.
Security note: Ensure Redis is bound to 127.0.0.1 (local only) and not exposed publicly. In most setups installed via the LS plugin, the default is localhost-only.
Step 2 — Confirm the PHP Redis extension
- In cPanel for the site, open Software → MultiPHP INI Editor (or use EasyApache 4 in WHM if managing globally).
- Create a test file
phpinfo.phpin your site’s document root with:
Load it in the browser and confirm the redis module is listed. Remove this file when you’re done.<?php phpinfo(); ?>
Step 3 — Configure CS-Cart to use Redis for cache
CS-Cart’s main local settings file is config.local.php in your CS-Cart root directory.
- Open
/home/USERNAME/public_html/path-to-cscart/config.local.phpin the cPanel File Manager editor. - Find the cache settings block (or add the lines if they don’t exist) and set Redis as the backend:
// --- CS-Cart cache backend --- $config['cache_backend'] = 'redis'; $config['redis_server'] = '127.0.0.1'; $config['redis_port'] = 6379; // Optional: use a dedicated Redis database index (0–15 by default in Redis) // $config['redis_db'] = 1; // uncomment to use DB 1 for cache // Optional: Redis connection timeout (seconds) // $config['redis_timeout'] = 1.0; - Save the file.
Tip: If you host multiple CS-Cart stores on the same server, use a different redis_db for each store to avoid key overlap.
Step 4 — (Optional) Store PHP sessions in Redis
You can keep sessions in the database (default) or move them to Redis. There are two reliable approaches; pick one:
Option A: CS-Cart session backend (preferred if your CS-Cart version supports it)
- Edit
config.local.phpagain and add:// --- CS-Cart sessions in Redis --- $config['session_backend'] = 'redis'; $config['session_redis_server'] = '127.0.0.1'; $config['session_redis_port'] = 6379; // Optional: separate DB for sessions // $config['session_redis_db'] = 2; // Optional: session connection timeout // $config['session_redis_timeout'] = 1.0; - Save the file.
Option B: PHP-level session handler (per domain)
- In cPanel for the domain, open Software → MultiPHP INI Editor (Editor Mode).
- Add or adjust:
Tip: Choose a differentsession.save_handler = redis session.save_path = "tcp://127.0.0.1:6379?database=2"databaseindex than you use for cache. - Save. No code changes needed in
config.local.phpfor this method.
Note: Only use one session method at a time. If you previously set $config['session_backend'], don’t also force PHP session handler via INI (and vice versa).
Step 5 — Clear CS-Cart cache
After changing cache or session configuration, clear CS-Cart cache so it rebuilds using Redis:
- Via URL query: append
?ccto your admin URL (e.g.,/admin.php?cc) and load it once while logged in. - Or delete cached files from
var/cache(andvar/themes_repositoryif needed) via cPanel File Manager:- Remove the contents of
var/cache/(do not delete the folder itself).
- Remove the contents of
Step 6 — Validate Redis usage
- Functional check: Browse the storefront and admin; pages should load normally.
- Redis activity: Use the LiteSpeed Redis screen in WHM or SSH:
redis-cli info keyspace redis-cli monitor # (watch keys briefly; CTRL+C to exit) - Optional PHP test:
You should seephp -r '$r=new Redis(); $r->connect("127.0.0.1",6379); echo $r->ping(), PHP_EOL;'PONG.
Troubleshooting
- White page / 500 error after enabling Redis: Revert the last changes in
config.local.php, clear cache, and confirm the PHP Redis extension is loaded (phpinfo). Then reapply settings carefully. - “Connection refused” or timeouts: Redis may not be running or not bound to
127.0.0.1. Check WHM → LiteSpeed → Redis status and the Redis configuration. - Session issues (users logged out unexpectedly): If you switched session storage, ensure only one session method is active (CS-Cart backend or PHP INI). Clear cache after any session change.
- Key collisions across sites: Assign a unique
redis_dbper store (and a different DB for sessions if you separate them). - Performance tuning: In heavy stores, consider Redis persistence (AOF), maxmemory policies, and server RAM sizing. Keep Redis local-only for security.
Roll-Back (Disable Redis)
- In
config.local.php, change:
and remove/comment any Redis lines you added for cache or sessions.$config['cache_backend'] = 'file'; - If you used PHP session handler, remove the
session.save_handlerandsession.save_pathoverrides from MultiPHP INI. - Clear CS-Cart cache again and retest.
That’s it! Your CS-Cart store should now be using Redis for fast, memory-based caching (and optionally sessions), with Redis provided by the LiteSpeed WHM plugin on your cPanel server.
