1.download redis-2.8.9.tar.gz from the official network, the redis decompress in/usr/local, the directory is a redis-2.8.9, and then according to the official site to install redis.
2. Run src/redis-server in the redis-2.8.9 directory after installation
Run src/redis-cli in another shell window to run the command correctly.
However, we obviously want to start running as a service.
3. The following describes how to configure redis as a Service. First, copy the utils/redis_init_script file to/etc/init. d.
Cp/usr/local/redis-2.8.9/utils/redis_init_script/etc/rc. d/init. d/redis copies redis_init_script to/etc/rc. d/init. d/, easy to name as redis
Then vi/etc/rc. d/init. d/redis
Add
# chkconfig: 2345 80 90
Then pay attention
EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli
Because our installation directory is/usr/local/redis-2.8.9, so the above two lines change
EXEC=/usr/local/redis-2.8.9/src/redis-server CLIEXEC=/usr/local/redis-2.8.9/src/redis-cli
Pay attention to
$EXEC $CONF
Add &
$EXEC $CONF &
"&" Means to forward the service to the end for running. Otherwise, when the service is started, the Redis service occupies the front-end and occupies the main user interface, causing other commands to fail to be executed.
4. You can see that there is such a line in the/etc/init. d/redis file:
CONF="/etc/redis/${REDISPORT}.conf"
Copy the redis configuration file to/etc/redis /.
mkdir /etc/redis cp /usr/local/redis-2.8.9/redis.conf /etc/redis/6379.conf
5. After completing the above operations, you can register the service:
chkconfig --add redis
Then start the redis Service
service redis start
Redis can run in Service Mode