Download and install redis
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
Essentials
redis-server
- Redis Serverredis-cli
- command line interface utility to talk with Redis
Make install
sudo make install
To execute or call redis-server
/redis-cli
without specifying full path.
Starting Redis
$ redis-server
[28550] 01 Aug 19:29:28 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[28550] 01 Aug 19:29:28 * Server started, Redis version 2.2.12
[28550] 01 Aug 19:29:28 * The server is now ready to accept connections on port 6379
... more logs ...
Check Redis if working
$ redis-cli ping
PONG
And its all done. Find out more at Official Redis Guide.
Add user redis
sudo useradd -s /bin/false -d /var/lib/redis -M redis
Create Redis pid file directory
sudo mkdir /var/run/redis/ -p && sudo chown redis:redis /var/run/redis
Create Redis config directory
sudo mkdir /etc/redis && sudo chown redis:redis /etc/redis -Rf
Create Redis logs directory
sudo mkdir /var/log/redis/ -p && sudo chown redis:redis /var/log/redis/ -Rf
Create Redis config and put it to /etc/redis/redis.conf
sudo mkdir /etc/redis
sudo cp redis.conf /etc/redis/redis.conf
sudo chown redis:redis /etc/redis/redis.conf
Change parameters in config with preferred text editor.
sudo vi /etc/redis/redis.conf
Add this minimum configuration example:
daemonize no
#where to put pid file
pidfile /var/run/redis/redis.pid
#loglevel and path to log file
loglevel warning
logfile /var/log/redis/redis.log
#set port to listen for incoming connections, by default 6379
port 6379
#set IP on which daemon will be listening for incoming connections
bind 127.0.0.1
#where to dump database
dir /var/lib/redis
Create Upstart file for Redis
sudo touch /etc/init/redis.conf
Put text below to /etc/init/redis.conf file
#!upstart
description "redis server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
exec sudo -u redis /usr/local/bin/redis-server /etc/redis/redis.conf
Start server
sudo service redis start
Add Redis to system startup
sudo update-rc.d redis defaults
Done. Find Redis formal setup in this link.
5. Configure Redis connection and default queue driver for laravel queueing
a. In
app/config/database.php
, change thedefault
settings to the correcthost
. Forport
leave it as ease.b. Also in
app/config/queue.php
, changedefault
toredis
. This will let redis manage all the queueing.Previous queueing were setup manually with cronjob, so no need to bother.