Nextcloud's current administration manual still documents the PhpRedis extension for Redis caching and transactional file locking. It also documents a newer, extension-free KeyValueCache backend added in Nextcloud 34.0.2. This guide uses the established PhpRedis configuration because Ubuntu 24.04 provides the PHP 8.3 Redis extension package. The newer backend is an option when your Nextcloud release supports it, but its configuration keys differ; do not mix the two examples.
The result will be a local Redis service available only to the Nextcloud host, Redis-backed distributed cache and file locking, and APCu for the faster local cache. This is a common single-server arrangement. If your web and PHP servers are split across hosts, use a shared Redis endpoint with appropriate network controls instead of the localhost settings below.
What Redis changes in a Nextcloud installation
Redis gives Nextcloud a key-value service for distributed cache entries and transactional file locks. Those locks help prevent conflicting operations when multiple requests work with files. Redis does not replace Nextcloud's database, file storage, PHP OPcache, or backup plan. On a single server, APCu is generally faster for local in-process caching, while Redis handles shared cache and locks. Nextcloud also cautions that using Redis as the local cache is not recommended, particularly with multiple web servers.
Nextcloud's latest manual identifies Redis as a supported backend and specifies PhpRedis 2.2.6 or newer for the extension-based method. Ubuntu 24.04's package archive includes php8.3-redis and redis-server. Package revisions can change as Ubuntu publishes updates, so install from the configured Ubuntu repositories rather than pinning a version copied from an older guide. References checked October 6, 2026: Nextcloud memory caching documentation, Ubuntu 24.04 PhpRedis package listing, and Ubuntu 24.04 Redis server package listing.
Before you begin
- Confirm the Nextcloud installation directory and the PHP runtime used by the website. The commands below assume a standard Ubuntu package installation with PHP 8.3, Apache or PHP-FPM, and the web service account
www-data.
- Back up
config/config.php and note how to restore it. The exact path varies: for example, a package install might use /var/www/nextcloud/config/config.php, while a manual installation may live elsewhere.
- Use a maintenance window if the server handles active file uploads. Restarting Apache or PHP-FPM briefly interrupts web requests.
1. Install Redis, PhpRedis, and APCu
Update package metadata and install the daemon and PHP extensions:
sudo apt update
sudo apt install redis-server php-redis php-apcu
Ubuntu's php-redis package selects the extension for the installed PHP version. If you maintain multiple PHP versions or use a third-party PHP repository, verify that the extension is installed for the exact PHP version serving Nextcloud. A module enabled for the command-line PHP runtime alone does not guarantee that Apache or PHP-FPM can load it.
Enable Redis at boot and start it now, then check its service state:
sudo systemctl enable --now redis-server
sudo systemctl status redis-server --no-pager
redis-cli ping
A healthy local Redis response to the last command is PONG. If the service is inactive, inspect sudo journalctl -u redis-server -n 50 --no-pager before changing Nextcloud's configuration.
2. Keep the Redis listener local
For a single-host installation, Redis does not need to listen on a public interface. Ubuntu's packaged configuration is normally designed for local access and protected mode; inspect /etc/redis/redis.conf before changing it:
sudo grep -E '^(bind|protected-mode|port|unixsocket)' /etc/redis/redis.conf
Keep Redis bound to loopback (commonly 127.0.0.1 and ::1) and leave protected mode enabled. Do not expose port 6379 to the internet or bind to 0.0.0.0 for this local setup. After any Redis configuration change, restart the service and repeat redis-cli ping.
This guide uses TCP on localhost to minimize socket-permission changes. A Unix socket is another supported local option and can reduce connection overhead, but the Redis socket path, group ownership, permissions, and Nextcloud configuration must all match. Follow the Nextcloud manual's socket example if you deliberately choose that route.
3. Confirm PHP can load both extensions
Check the command-line PHP modules:
php -m | grep -Ei '^(apcu|redis)$'
You should see both names. If one is missing, check the enabled module files with php --ini and install the matching package for your PHP version. Restart the PHP handler used by the website so its workers load the new modules. For Apache with mod_php, run sudo systemctl restart apache2. For a PHP-FPM installation using PHP 8.3, run sudo systemctl restart php8.3-fpm; restart or reload the web server as your deployment requires.
The CLI check is a useful first signal, not complete proof of the web runtime. Later, use Nextcloud's Administration settings and its server information or PHP information view to verify that the web process recognizes the cache modules.
4. Add the cache settings to Nextcloud
Open the existing config/config.php with an editor. Back up the file first, and merge these entries into the existing PHP array before its closing );. Do not replace the whole file or add a second copy of keys that are already present.
'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
],
The explicit loopback address matches the local Redis service. If you instead use a Unix socket, use the socket path as the Redis host and configure the daemon and permissions to match. If Redis requires authentication, add the correct Redis ACL username and password to the redis array and configure Redis accordingly; never paste a real password into a shared example or public support post.
Keep existing settings such as instanceid, database credentials, trusted domains, and data directory unchanged. PHP array syntax matters: keep commas between entries and make sure each setting appears only once.
5. Validate the cache and file locking
Run Nextcloud's command-line status check from the installation directory as the web-service user. Replace the example path if your installation is elsewhere:
cd /var/www/nextcloud
sudo -u www-data php occ status
Check the web interface under Administration settings for setup warnings, and confirm the Redis and APCu modules are visible to the web PHP runtime. Then test normal file operations with a small, noncritical file: upload it, rename it, download it, and delete it. The admin page should no longer report that a memory cache is missing when the local cache is correctly configured.
A successful PONG only proves that Redis responds to the local CLI client. The Nextcloud admin check and routine file operations help verify the PHP extension, web-server permissions, Redis connection settings, and application configuration together. Do not treat a faster page load during one test as proof of a measured performance improvement; workload, storage, database, and PHP worker capacity all affect response time.
Troubleshooting common problems
The admin page still reports no memory cache
Check for a duplicate or misspelled cache key, confirm that memcache.local points to APCu, and restart the correct Apache or PHP-FPM service. A CLI-only PHP installation may be different from the PHP runtime used by the website.
Redis is running, but Nextcloud reports connection errors
Compare the host and port in config.php with the listener in /etc/redis/redis.conf. Confirm local access with redis-cli -h 127.0.0.1 -p 6379 ping and review Redis and web-server logs. If you use a socket or password, verify that its path or credentials match on both sides.
File operations fail after the change
Temporarily restore the backed-up config.php if the instance becomes unusable, then inspect the PHP and web-server logs. Check array punctuation, confirm the Redis service is active, and verify that no firewall or custom Redis ACL blocks the web process. Avoid clearing Redis data as a first troubleshooting step; investigate the connection and configuration before removing cache or lock entries.
What this setup does not cover
This is a single-server configuration, not a high-availability Redis design. It does not configure Redis replication, Sentinel, TLS, a remote cache host, session storage, or a clustered Nextcloud deployment. Multi-server Nextcloud nodes must share the same distributed cache and locking backend; localhost on each node would create separate Redis instances and defeat that requirement. For a remote or clustered topology, follow the matching Nextcloud configuration section and secure Redis communications for that environment.
After the configuration is stable, monitor Redis memory usage and Nextcloud's Administration overview. Allocate enough memory for cache and lock activity, avoid unreviewed eviction policies that could discard lock data, and keep normal database and file backups. Redis caching can reduce cache and locking overhead, but it is one part of a healthy Nextcloud installation rather than a substitute for capacity planning.