Following previous article http://www.cnblogs.com/EasonJim/p/7599941.html after installing Redis, assume that the file is already installed in the/usr/local/redis directory. Let's say I installed a version of redis-4.0.2.
1. Configure Service Scripts
There is a redis_init_script file under Redis-4.0.2/utils, this is Sysvinit's service script.
sudo cp UTILS/REDIS_INIT_SCRIPT/ETC/INIT.D/REDISD
As the system boot service name (ending in D is the self-starting service, it is customary).
Open the startup directory for file modification files
sudo VIM/ETC/INIT.D/REDISD
redisport=6379EXEC=/usr/local/redis/bin/redis-servercliexec=/usr/local/redis /bin/redis-clipidfile=/var/run/redis_${redisport}. pidconf= "/etc/redis/${redisport}.conf"
2. Configuration files
In the source root directory has a redis.conf configuration file, copy and modify the name, note that the name and the above/etc/redis/${redisport}.conf configuration corresponds.
mkdir /etc/redissudo cp redis. conf/etc/redis/6379.conf
Open the file to modify the contents as follows:
# Set the background to run daemonize Yes#/var/log/redis/redis-server. Log # Set Persistent file storage path dir
Note: Several of the above directories are not available and need to be created after the folder
mkdir /var/log/mkdir /var/lib/redis
3. Using UPDATE-RC.D Registration Service
#+x/etc/init.d/REDISD# Registration service sudo update-rc. D/ETD/INIT.D/REDISD defaults
4, the service commonly used commands
#start # shutdown Service sudo service REDISD stop # Restart services: sudo service REDISD restart
5. Troubleshooting
The services set above do not necessarily start normally, you can usually run with/ETC/INIT.D/REDISD start and then go inside the/var/log/redis/directory to see the log to troubleshoot errors, which is the path to the service script settings.
Reference:
http://blog.csdn.net/softwave/article/details/53838194
Ubuntu 16.04 set up Redis for boot auto start service