0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
JPPINTO
  • Home
  • Blog
  • Certifications
  • About
  • Contact
  • Shop
  • Gallery
  • Current Setup
Contact

Search

July 3, 2026 / Linux, Servers, Ubuntu

Install and Configure Redis on Ubuntu for Local Object Cache

Tags: linux, object cache, redis, server setup, ubuntu, wordpress
Featured image for Install and Configure Redis on Ubuntu for Local Object Cache

Redis is often used as a local object cache for WordPress and other web applications. It can reduce repeated database work by keeping frequently used values in memory.

This guide shows how to install Redis on Ubuntu, bind it to local addresses, set a memory limit, choose an eviction policy, validate memory, and restart the service.

What the Script Does

The deployment script this article is based on:

  • Installs redis-server.
  • Enables the Redis service.
  • Backs up /etc/redis/redis.conf.
  • Sets bind address, port, memory limit, eviction policy, backlog, and timeout.
  • Keeps protected mode enabled.
  • Runs a Redis memory test.
  • Restarts and verifies the Redis service.

Install Redis

Run:

sudo apt update
sudo apt install -y redis-server
sudo systemctl enable redis-server

Check the service:

sudo systemctl status redis-server

Back Up the Redis Config

Before editing Redis, create a backup:

sudo mkdir -p /opt/server-backups/redis
timestamp="$(date +%Y%m%d%H%M%S)"
sudo cp /etc/redis/redis.conf "/opt/server-backups/redis/redis.conf.before.${timestamp}.bak"

Apply Local Cache Settings

This example uses Redis as a local service:

  • Bind address: 127.0.0.1 ::1
  • Port: 6379
  • Max memory: 2gb
  • Eviction policy: allkeys-lru
  • Protected mode: yes

Apply the settings:

sudo sed -i "s/^bind .*/bind 127.0.0.1 ::1/" /etc/redis/redis.conf
sudo sed -i "s/^port .*/port 6379/" /etc/redis/redis.conf
sudo sed -i "s/^# maxmemory .*/maxmemory 2gb/" /etc/redis/redis.conf
sudo sed -i "s/^# maxmemory-policy .*/maxmemory-policy allkeys-lru/" /etc/redis/redis.conf
sudo sed -i "s/^tcp-backlog .*/tcp-backlog 511/" /etc/redis/redis.conf
sudo sed -i "s/^timeout .*/timeout 0/" /etc/redis/redis.conf

Make sure protected mode is enabled:

sudo grep -q "^protected-mode yes" /etc/redis/redis.conf || echo "protected-mode yes" | sudo tee -a /etc/redis/redis.conf >/dev/null

For a single-server WordPress setup, binding Redis to localhost is usually the right default. Do not expose Redis directly to the public internet.

Test and Restart Redis

Run a basic memory test:

sudo redis-server /etc/redis/redis.conf --test-memory 2 >/dev/null

Back up the after-change config:

sudo cp /etc/redis/redis.conf "/opt/server-backups/redis/redis.conf.after.${timestamp}.bak"

Restart Redis:

sudo systemctl restart redis-server
sudo systemctl is-active --quiet redis-server

Test with redis-cli:

redis-cli ping

Expected output:

PONG

Troubleshooting

If Redis will not restart, check:

sudo systemctl status redis-server
sudo journalctl -u redis-server -xe

If redis-cli ping fails, confirm Redis is listening on the expected address and port:

ss -ltnp | grep 6379

Quick Reference

sudo apt install -y redis-server
sudo systemctl enable redis-server
sudo systemctl restart redis-server
redis-cli ping

Redis is powerful, but keep it local unless you have a specific secured network design. For WordPress object caching on one server, localhost Redis is usually enough.

Post Views: 33
<- Install and Configure MySQL on Ubuntu for WordPress
Create an Nginx Default Catch-All Site on Ubuntu ->

Categories

  • Active Directory (5)
  • AI (2)
  • Amazon Cloud Services (1)
  • Blazor (1)
  • C# (C-Sharp) (3)
  • CI/CD Pipelines (1)
  • Containers (4)
  • Deployment (2)
  • Development (4)
  • Docker (3)
  • General (5)
  • IIS 6.0 (4)
  • IIS 7.0 (10)
  • IIS 8.0 (1)
  • Infrastructure as Code (IaC) (1)
  • Kubernetes (3)
  • Linux (8)
  • Microsoft 365 (2)
  • MySQL (1)
  • Office 2010 (1)
  • PHP (1)
  • PowerShell (7)
  • Productivity (1)
  • Servers (8)
  • SharePoint 2007 (8)
  • SharePoint 2010 (19)
  • SharePoint 2013 (2)
  • SharePoint Online (1)
  • SMTP (4)
  • SQL Server 2008 (1)
  • SQL Server 2008 R2 (1)
  • SQL Server 2012 (2)
  • SQL Server 2019 (1)
  • Ubuntu (8)
  • Uncategorized (1)
  • URL Rewrite (2)
  • Visual Studio 2019 (1)
  • Visual Studio Code (1)
  • Windows 10 (5)
  • Windows 2003 (9)
  • Windows 2008 (18)
  • Windows 2012 (6)
  • Windows 7 (3)
  • Windows Firewall (1)
  • Windows Vista (1)
  • WordPress (3)
  • WP-CLI (3)

Recent Posts

  • Create an Nginx Default Catch-All Site on Ubuntu
  • Install and Configure Redis on Ubuntu for Local Object Cache
  • Install and Configure MySQL on Ubuntu for WordPress
  • Install PHP-FPM and Common PHP Extensions on Ubuntu
  • Install and Tune Nginx on Ubuntu for Web Hosting

Advertisement

Tags

ai coding agents bash developer workflow dev to production exe permissions externalize blob externalize sharepoint data filezilla server firewall rules filazilla full installation http redirect https https redirect IIS iis7 iis 7 installation IIS installation index server configuration installing cumulative updates linux load balance central administration microsoft 365 nginx nlb powerpoint powershell redirect http to https server setup sharepoint 2010 cumulative updates sharepoint 2010 farm build sharepoint 2010 farm configuration sharepoint 2010 farm installation sharepoint data externalization SMTP storagepoint ubuntu web server windows Windows 7 windows firewall configuration windows server 2008 wlbs wordpress wp-cli x86
© 2026 JPPinto.com. All rights reserved.