• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / tutorials / redis install ubuntu 20.04 with wordpress php redis mysql configuration

redis install ubuntu 20.04 with wordpress php redis mysql configuration

Table of Contents

Toggle
  • Redis installation on ubuntu 20.04
  • 2nd redis server configuration
    • step 3 restart reload  redis
    • check port redis running or not
    • php 7 install redis extension
  • How to use redis wordpress
    • #1 Installing php redis extension
    • #2 by Enable Redis object cache in w3 Total cache
    • #3 Edit wp-config.php file  (no need redis plugin installed)
    • #2nd way  install redis object cache plugin
    • Verify if Redis working with redis-cli monitor
    • Retrieving All Existing Keys
  • using redis and mysql together
  • Reinstall Uninstall & install redis on Ubuntu 20.4
  • Installing Redis from source
    • 2.working with redis configuration file
    • 3.Create Redis systemd Unit File
    • 4.Creating User /group /directories and permissions
  • APcu vs Memcached vs Redis
    • ACPU Installation
  • enable memcached plugin with mysql
  • how to use memcached with wordpress
  • #1 install memcached ubuntu / debian family
    • #1.1 configuring memcached  conf memory limit
    • #2 install php -memcached extension from github
    • #3 Edit wp-config.php file
    • #4 install w3tc

Redis installation on ubuntu 20.04

 

1st step: update & install redis server form ubuntu repository

sudo apt update && sudo apt install redis-server

 

2nd redis server configuration

edit

sudo nano /etc/redis/redis.conf

 

change:

: supervised no // change here

supervised systemd

then it runs as a service

bind local or remote address

bind 127.0.0.1 ::1

maxmemory 256mb
maxmemory-policy allkeys-lru

step 3 restart reload  redis

systemctl restart redis

systemctl status redis

check port redis running or not

sudo netstat -lnp | grep redis

to check ports

redis-cli

send ping then it returns pong.

php 7 install redis extension

apt-get install php-redis
check redis module or not by typing
php -m | grep redis
PHP Warning: Module ‘redis’ already loaded in Unknown on line 0
redis
supports PHP 7 then don’t go for manual installation.

How to use redis wordpress

installing and configuring Redis, >> installing a PHP extension, >>Redis Object Cache plugin.

#1 Installing php redis extension

apt-get install redis
apt-get install php-redis
Quick & easy but not the latest version.

#2 by Enable Redis object cache in w3 Total cache

Performance (w3tc)>> General settings>> page cache>>

  1. Disc basic
  2. Disc enhance
  3. Php Apcu
  4. Redis  (it will available once you load redis PHP extension)

 

#3 Edit wp-config.php file  (no need redis plugin installed)

define(‘WP_CACHE’, true);
define(‘WP_CACHE_KEY_SALT’, ‘yoursite.com’);

Note: object-cache.php (generated by any plugin) should be ar wp-content directory.

#2nd way  install redis object cache plugin

Redis Object Cache for wordpress by plugin

 

if root access then try this command. shared hosting servers may not offer this.

redis-cli monitor

Verify if Redis working with redis-cli monitor

redis-cli monitor

When you run this command, you will see the real-time output of Redis serving cached queries. If you don’t see anything, visit your website and reload a page.

Go to the terminal and access Redis CLI using redis-cli and the KEYS *

Retrieving All Existing Keys

It may ruin performance when it is executed against large databases.

> KEYS *
1) "title:1"
2) "title:2"
3) "title"
4) "author:2"
5) "author"
6) "author:1"

using redis and mysql together

Redis is an in-memory databases,  faster as compare to query the data from hdd MYSQL. also read mysql buffer pool cache

how to use redis with mysql database in Apache nginx

redis php extension from github (predis library from github), or wordpress directory

mysql smart plugin,

like memcached plugin for mysql

InnoDB memcached plugin ( daemon_memcached ) provides an integrated memcached daemon.

 

memcached storage is low,
php acp dead and rebuild as APCu.  store cache in the PHP shared memory (memory-hog >>opcode cache memory, php process memory may unstable>> due to high memory allocated to a single php process when you increase over all php memory)

 

Reinstall Uninstall & install redis on Ubuntu 20.4

sudo apt-get remove

sudo apt-get purge redis-server

//pyrhe removes config files

 

apt install redis-server

check status

service redis-server status

root@-s-4vcpu-8gb-blr1-01:~# service redis-server status
● redis-server.service – Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) sin

 

ps aux | grep redis

edit redis configuration file

restart

service redis-server start

MySQL and Redis drivers

Installing Redis from source

Latest version 4.0
http://download.redis.io/redis-stable.tar.gz
redis as server
Using Redis as an LRU cache
Installing from source & compile at the server
sudo apt-get update
sudo apt install build-essential
cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz &&  cd redis-stable
make && make install
cleaning temp directory
cd..

2.working with redis configuration file

sudo mkdir /etc/redis &&  cp redis.conf /etc/redis/
sudo nano /etc/redis/redis.conf
maxmemory 128mb
maxmemory-policy allkeys-lru
supervised no (change)
supervised systemd
working directory
dir ./
change to
dir /var/lib/redis

3.Create Redis systemd Unit File

sudo nano /etc/systemd/system/redis.service
copy & paste the below code

[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

save the file by CTRL+X and type and hit enter.

4.Creating User /group /directories and permissions

sudo adduser –system —group –no-create-home redis &&  mkdir /var/lib/redis && chown redis:redis /var/lib/redis && chmod 770 /var/lib/redis

start

sudo systemctl start redis

stop

sudo systemctl stop redis

restart

sudo systemctl restart redis

Enable Redis on every Bootup

sudo systemctl enable redis
testing:
netstat -lntp to know all listening ports
# redis-cli
127.0.0.1:6397>>ping
you will get pong
Redis configuring with PHP
install the Redis Object Cache Plugin.

 

APcu vs Memcached vs Redis

implementing Object cache with APCu, Redis for wordpress memcached comparison
>> No need to communicate with another server.
>>NO TCP Connection (to PHP & MySQL)
>> ACpu stores in php shared memory (no separate memory allocation needed, this can cause memory -hog I need to increase PHP memory size and figure out how much MySQL using)
APCu
Does not share the cache with other servers but is faster (maybe)
single machine.
why Redis among Memcached and php apcu?
more features than memcached.

ACPU Installation

from repository
check your distribution version
lsb_release -a
Description: Ubuntu 18.04.1 LTS
step 1: 
sudo apt-get install php7.2-apcu -y
step 2:
nano /etc/php/7.2/mods-available/acpu.ini
add the following adjusting memory size
extension=apcu.so
apc.shm_size = “50M”
check php enabled modules by
php -m
restart
step 3:
service php7.2-fpm restart
step 4:
go to w3tc >>general settings>> object cache>> Apc/apcu.

nano /etc/php/7.0/mods-available/apcu.ini
extension=apcu.so
apc.shm_size = “40M”
nano /etc/php/7.0/mods-available/redis.ini
apc
opcache settings for WordPress
don’t disable timestamps. it caches all unnecessary PHP file from /wp-includes and wp-admin/
don’t set large amount memory.
validate settings should be low.

enable memcached plugin with mysql

libmemcached.so: the memcached daemon plugin to MySQL.

innodb_engine.so: an InnoDB API plugin to memcached.

libevent must be installed.

sudo apt-get install libevent-dev

2. step

 

mysql> source MYSQL_HOME/share/innodb_memcached_config.sql

mysql> USE innodb_memcache;
mysql> SHOW TABLES;

Activate the daemon_memcached plugin by running the INSTALL PLUGIN statement:

mysql> INSTALL PLUGIN daemon_memcached soname “libmemcached.so”;

telnet localhost 11211

read more here

how to use memcached with wordpress

memcached used by youtube,fb,twitter, why don;t you. easy to configure.
matured than redis.

#1 install memcached ubuntu / debian family

sudo apt-get update && sudo apt-get install memcached

sudo apt-get install libmemcached-tools (optional)

#1.1 configuring memcached  conf memory limit

sudo nano /etc/memcached.conf

default values are enough but 64mb memory

binding
add top of the file if not
-l 127.0.0.1

disable UDP
add bottom of the file
. . .
-U 0

uncomment
. . .
-vv
to enable logging
/var/log/memcached

memory allocation

Locate the -m parameter.
value to MB or GB based on DB size frequently accessed data.

256MB for low end servers 512MB 1Gb as per need.

 

sudo systemctl restart memcached

check
telnet localhost 11211
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
exit memcached telnet
quit
Connection closed by foreign host.
or
ps aux | grep memcached
stop memcached
sysctl stop memcached
sysctl disable memcached

#2 install php -memcached extension from github

sudo apt-get install -y php-memcached
(if not works add ppa repository / install from source github)

#3 Edit wp-config.php file

define(‘WP_CACHE’, true);
define(‘WP_CACHE_KEY_SALT’, ‘yoursite.com’);

define(‘WP_CACHE’, true); // Added by W3 Total Cache

#4 install w3tc

used memached for object cache. not page cache (if it done by fastcgi)
Conclusion: i have tried both Apcu and Redis in the past. installed Memcached on the test server as of far i don’t remember about Memcached. its a tie between redis and Apcus. (both Memcached & redis are distributed but Apcu works only for local machine)
Reference:
https://guides.wp-bullet.com/install-redis-object-cache-for-wordpress-php-7-on-ubuntu-16-04/
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04

Primary Sidebar

tutorials

  • Core Java Tutorial Free online
  • HTML & CSS Tutorials
  • Php tutorials
  • ubuntu tutorials installation download issues etc
  • redis install ubuntu 20.04 with wordpress php redis mysql configuration
    • redis config file location ubuntu config settings
    • redis wordpress (install, configure, tweak performance ) compared with memcached
    • redis slowlog enable disable view logs keys examples
  • [INTRO] Ethical hacking / cyber Security / Penetration testing Tutorial -{updates frequently}
  • Android Studio tutorials syllabus Topics Course details #AndroidApplicationDevelopment
  • AUdio Editing Background Noise removal (Audacity, Adobe Premiere Addition, Camtasia Filmora Windows Obs)
  • what is vpn vs proxy vs tor, http vs https, http2, tcp vs udp, kali linux sql source code injection
  • how to create a website free of cost on google
  • CCNA Syllabus pdf (CCNA / CCNP vs devops vs mcsa /MCSE)
  • Redis performance metrics & tuning for nginx apache ubuntu & debian
  • xampp tutorials 2021 installation errors fix wordpress phpmyadmin mysql apache
  • new relic installation linux (infrastructure agent , php, mysql , nginx)
  • new relic mysql install integration - 2 ways fix problems
  • new relic php agent install in 3 steps
  • aws load balancer tutorial
  • git branches merge fetch pull conflicts

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy