Part I: Installing Redis
Now we will install Redis into this directory/usr/local/redis
You want to download the installation package to this directory/USR/LOCAL/SRC
Then the installation process instructions are as follows:
$ Mkdir/usr/local/redis $ cd/usr/local/src $ wget http://download.redis.io/releases/redis-3.0.6.tar.gz$ tar XZF redis-3.0.6.tar.gz $ ln-s redis-3.0.6 redis #建立一个链接 $ cd redis $ make Prefix=/usr/local/redis install #安装 to the specified directory
(Note: Redis official address: http://www.redis.io/Latest version: 3.0.6)
Note the last line above, we specified the installed directory through prefix. If make fails, it is common that GCC is not installed in your system, so you can install it via yum:
Yum Install GCC
After the installation is complete, continue with make.
After you have successfully installed Redis, you will be able to see a bin directory in/usr/local/redis that includes the following files:
Redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
Part II: Making Redis a service
1. Copy the script to the/ETC/RC.D/INIT.D directory
PS: The script in the/etc/rc.d/init.d/directory is similar to the registry in Windows, and some of the specified scripts will be executed when the system is started
When you install Redis as per the above steps, its service script is located at:
/usr/local/src/redis/utils/redis_init_script
It must be copied to the/ETC/RC.D/INIT.D directory:
Cp/usr/local/src/redis/utils/redis_init_script/etc/rc.d/init.d/redis
Copy the Redis_init_script to/etc/rc.d/init.d/and easily name Redis.
If you add a registration service at this point:
Chkconfig--add Redis
The following error is reported: Redis service does not support Chkconfig
To do this, we need to change the Redis script.
2. Change the Redis script
Open the script using VI to view the script information:
Vim/etc/rc.d/init.d/redis
What you see is as follows (the following is a change of good information):
#!/bin/sh #chkconfig: 2345 # simple Redis INIT.D script conceived to work on Linux systems # as it does use of the/ Proc FileSystem. redisport=6379 Exec=/usr/local/redis/bin/redis-server cliexec=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/ Redis_${redisport}.pid conf= "/etc/redis/${redisport}.conf" case "$" in start) if [-F $PIDFILE] t Hen echo "$PIDFILE exists, process is already running or crashed" else echo "Start ing Redis server ... "$EXEC $CONF & fi; STOP) if [!-F $PIDFILE] then echo ' $PIDFILE does not exist, process was not running " Else pid=$ (cat $PIDFILE) echo "Stopping ..." $CLIEXEC-P $REDISPORT s Hutdown while [-x/proc/${pid}] does echo "Waiting for Redis to Shutdo WN ... "Sleep 1 doNe echo "Redis stopped" FI;; *) echo "Please use Start or stop as first argument";; Esac
Compared to the original configuration file:
1. The original document does not have the contents of line 2nd below,
2. The original file exec, cliexec parameters, is also changed.
Exec=/usr/local/redis/bin/redis-server
3.redis commands that are enabled to run in the background. (skipped)
PS: Note that the "&" in the back, that is, to move the service back to the meaning of running, otherwise when the service is started, the Redis service will
Occupy the front desk, occupying the main user interface, resulting in other commands not being executed.
4. Copy the Redis configuration file to/etc/redis/${redisport}.conf
Mkdir/etc/redis cp/usr/local/src/redis/redis.conf/etc/redis/6379.conf
In this way, the conf specified by the Redis service script exists. By default, Redis does not have authentication enabled, and you can specify a verification password by turning on the requirepass of 6379.conf.
Once the above operation is complete, you can register the Yedis service:
Chkconfig--add Redis
3. Start the Redis service
Third, add the directory where the Redis command resides to the system parameter path
To modify a profile:
Vi/etc/profile
Append in last line:
export PATH=
"$PATH:/usr/local/redis/bin"
Then apply this file immediately:
. /etc/profile
This makes it possible to invoke the REDIS-CLI command directly, as follows:
$ redis-cli redis 127.0.0.1:6379> auth cicl OK redis 127.0.0.1:6379> ping PONG Redis 127.0.0.1:6379>
(auth cicl Skip)
At this point, Redis is installed successfully.
Summary: Installing Redis in a Linux system can be more or less problematic. In this installation, 3 of the most
1. Download, install, use here to the wget command, make command, I do not understand the use of make command, and always worry about how the make command installed in the specified directory, this time finally understand.
2. How to add a program to the service, of course, also have a knowledge of/etc/rc.d/init.d this file.
3. How to add some commands of a program to the system parameters, enter the command directly to achieve the operation of a program.
is to specify a good environment variable.
>> installing Reids and PHP Redis extensions under Windows
Installing Redis under Linux