Redis

Multiples instances

Create a folder with the install command: install -o redis -g redis -d /var/lib/redis_6380

Copy the current redis configiration to a new file: sudo cp -p /etc/redis/redis.conf /etc/redis/redis_6380.conf

Editer tha new configuration file: vi /etc/redis/redis_6380.conf and change the values accordingly:

port 6380
pidfile /var/run/redis/redis-server-6380.pid
logfile /var/log/redis/redis-server-6380.log
databases 2
dir /var/lib/redis_6380

Copy the current redis service configuration file: sudo cp /lib/systemd/system/redis-server.service /lib/systemd/system/redis-server-6380.service

Edite the file vi /lib/systemd/system/redis-server-6380.service and change the values accordingly:

ExecStart=/usr/bin/redis-server /etc/redis/redis_6380.conf
PIDFile=/run/redis/redis-server-6380.pid
ReadWritePaths=-/var/lib/redis_6380
Alias=redis_6380.service

Enable the service: systemctl enable redis-server-6380.service

Start the service: systemctl start redis-server-6380.service

Check if it is running: systemctl status redis-server-6380.service and that you can connect: redis-cli -p 6380

Laravel changes

After this you can change the laravel configuration file, since now we only need 2 databases, they can be 0 and 1

REDIS_PORT=6380
REDIS_DB_NUM=0
REDIS_DB_CACHE=1

And change the laravel-echo-server.json file also:

...

databaseConfig": {
    "redis": {
            "port": "6380",
            "host": "127.0.0.1",
            "options": {
                    "db": 1
            }
    },

...

Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to make your changes.