Install Redis Cache
using the below command
sudo apt install redis
If you want to install from source code, use below step
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
Configure Redis Cache
using the below command
sudo nano /etc/redis/redis.conf
Replace the #maxmemory
to the below line
maxmemory 128mb
maxmemory-policy allkeys-lfu
Save the file by pressing Ctrl + o
then press Enter key then press Ctrl + x
Restart Redis Cache
server and test using the below command
sudo service redis-server restart
redis-cli ping
Add PhpRedis
using the below command
# check stable version of release we use development version
https://github.com/phpredis/phpredis/archive/refs/heads/develop.zip
unzip develop.zip
cd phpredis-develop
phpize
./configure
make
sudo make install
For Apache, follow the below steps, Note: change 7.x
with your PHP version
sudo echo "extension=redis.so" > /etc/php/7.x/apache2/conf.d/redis.ini
apache2ctl restart
For Nginx, follow the below steps, Note: change 7.x
with your PHP version
echo "extension=redis.so" > /etc/php/7.x/mods-available/redis.ini
ln -sf /etc/php/7.x/mods-available/redis.ini /etc/php/7.x/fpm/conf.d/20-redis.ini
ln -sf /etc/php/7.x/mods-available/redis.ini /etc/php/7.x/cli/conf.d/20-redis.ini
service php7.x-fpm restart
service nginx restart