104 lines
2.7 KiB
Markdown
104 lines
2.7 KiB
Markdown
---
|
|
title: "Some Redis installation notes"
|
|
date: 2019-01-25
|
|
last_modified_at: 2023-10-21
|
|
url: some-redis-installation-notes
|
|
layout: post
|
|
category: Tutorials
|
|
image: /img/blog/some-redis-installation-notes.png
|
|
description: "A blog post with a full and viable Redis installation procedure on Debian"
|
|
---
|
|
|
|
[![A missing blog post image](/img/blog/some-redis-installation-notes.png)](/img/blog/some-redis-installation-notes.png)
|
|
|
|
### Introduction
|
|
|
|
I've just achieved one more Redis installation today, and as the previous ones, I had to browse the WEB again, looking for the same pieces of information.
|
|
You'll find below my Redis-installation-memo (at least for me, in the future).
|
|
|
|
No slow listening TCP sockets. Only a hardened UNIX one.
|
|
No boot warnings. Only Linux kernel tweaks.
|
|
Not _so_ many databases. Only what we usually need.
|
|
No hand-made Bash scripts for standalone program administration. Only a systemd-supervised instance.
|
|
|
|
> A procedure powered by Debian :heart:
|
|
|
|
**EDIT 2019-11-11 : This post has been updated, extending compatibility to Debian Buster !**
|
|
|
|
**EDIT 2021-08-07 : This post has been updated (again), according to Debian Bullseye new requirements. You may browse previous revisions of it [here](https://git.forestier.app/HorlogeSkynet/blog/commits/branch/master/_posts/2019-01-25-some-redis-installation-notes.md).**
|
|
|
|
### The procedure
|
|
|
|
{% highlight bash %}
|
|
apt install -y redis-server
|
|
|
|
systemctl stop redis-server.service
|
|
|
|
nano /etc/redis/redis.conf
|
|
: '
|
|
# ...
|
|
port 0
|
|
# ...
|
|
unixsocket /run/redis/redis-server.sock
|
|
unixsocketperm 770
|
|
# ...
|
|
supervised systemd
|
|
# ...
|
|
pidfile /run/redis/redis-server.pid
|
|
# ...
|
|
databases 1
|
|
# ...
|
|
requirepass <at-least-a-64-byte-long-random-string>
|
|
'
|
|
|
|
systemctl edit redis-server.service
|
|
: '
|
|
[Service]
|
|
Type=notify
|
|
TimeoutStartSec=infinity
|
|
# If running in non-cluster mode:
|
|
ProtectSystem=full
|
|
'
|
|
|
|
sysctl -w vm.overcommit_memory=1
|
|
echo 'vm.overcommit_memory = 1' > /etc/sysctl.d/redis.conf
|
|
|
|
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
|
|
nano /etc/default/grub
|
|
: '
|
|
# ...
|
|
GRUB_CMDLINE_LINUX_DEFAULT="[...] transparent_hugepage=never"
|
|
# ...
|
|
'
|
|
update-grub2
|
|
|
|
systemctl start redis-server.service
|
|
{% endhighlight %}
|
|
|
|
At this time the server should be up and running, you may want to check that everything went fine this way :
|
|
|
|
{% highlight bash %}
|
|
systemctl status redis-server.service
|
|
tail -f /var/log/redis/redis-server.log
|
|
{% endhighlight %}
|
|
|
|
---
|
|
|
|
For Redis usage from PHP-based applications you'll need :
|
|
|
|
{% highlight bash %}
|
|
usermod -a -G redis www-data
|
|
|
|
# Using `mod_php` ?
|
|
systemctl restart apache2
|
|
|
|
# Using FPM ?
|
|
systemctl restart php7.X-fpm
|
|
{% endhighlight %}
|
|
|
|
---
|
|
|
|
### Conclusion
|
|
|
|
No conclusion. It should work, even for you, young Web-wanderer.
|