The method of installing Redis in Centos 7
This article is about how to install Redis in Centos 7. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First, install gcc dependencies
Redis is developed in C language, before installation, you must confirm whether to install the gcc environment (gcc-v), if not, execute the following command to install.
$yum install-y gcc II. Download and extract the installation package $wget http://download.redis.io/releases/redis-5.0.7.tar.gz$ tar-zxvf redis-5.0.7.tar.gz III. Switch to the redis directory for cd. Execute compilation $cd redis-5.0.7 & & make IV, install and specify the installation directory $make install PREFIX=/usr/local/redis V, startup service 5.1 foreground launch $cd / usr/local/redis/bin/$. / redis-server5.2 background startup
Copy redis.conf from the redis source directory to the redis installation directory
$cp / usr/local/redis-5.0.7/redis.conf / usr/local/redis/bin/
Modify the redis.conf file to change daemonize no to daemonize yes
$vim redis.conf## GENERAL # # By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in / var/run/redis.pid when daemonized.daemonize yes
Background start
$. / redis-server redis.confession VI. Set boot
Add Boot Startup Service
$vim / etc/systemd/system/redis.service
Add the following
[Unit] Description=redis-serverAfter=network.target [Service] Type=forkingExecStart=/usr/local/redis/bin/redis-server / usr/local/redis/bin/redis.confPrivateTmp= true[Install] WantedBy=multi-user.target
Note: ExecStart is configured with its own path
Set up boot boot
$systemctl daemon-reload$ systemctl start redis.service$ systemctl enable redis.service
Create a redis command soft link
$ln-s / usr/local/redis/bin/redis-cli / usr/bin/redis# test $redis127.0.0.1:6379 > pingPONG127.0.0.1:6379 >
Finally, post some common commands.
# start redis Service systemctl start redis.service# stop redis Service systemctl stop redis.service# restart Service systemctl restart redis.service# View Service current status systemctl status redis.service# Settings Boot systemctl enable redis.service# stop Boot systemctl disable redis.service
OK~ finished ~
Thank you for reading! This is the end of this article on how to install Redis in Centos 7. I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!