Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install redis for centos7

Shulou Source: shulou.com Published: 2022-06-01 00:40:55 09月21日 Update

This article is a detailed introduction to "how to install redis in centos7" for everyone. The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how to install redis in centos7" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of the small editor.

1. Install GCC dependency

Since redis is developed in C language, confirm whether to install gcc environment (gcc -v) before installation. If not, execute the following command to install

[root@localhost local]# yum install -y gcc 2. Download and extract the installation package [root@localhost local]# wget http://www.localhostlocalhostlocal.com//download.redis.io/releases/redis-5.0.3.tar.gz [root@localhost local]# tar -zxvf redis-5.0.3.tar.gz 3. cd Switch to redis decompression directory and execute compilation [root@localhost local]# cd redis-5.0.3[root@localhost redis-5.0.3]# make 4. Install and specify installation directory [root@localhost redis-5.0.3]# make install PREFIX=/usr/local/redis 5. Startup Services 5.1 Front Desk Startup [root@localhost redis-5.0.3]# cd /usr/local/redis/bin/[root@localhost bin]# ./ redis-server 5.2 background startup

Copy redis.conf from redis source directory to redis installation directory

[root@localhost bin]# cp /usr/local/redis-5.0.3/redis.conf /usr/local/redis/bin/

Change redis.conf file to daemonize yes instead of daemonize no

[root@localhost bin]# vi redis.conf

background starts

[root@localhost bin]# ./ redis-server redis.conf VI. Set boot startup

Add boot service

[root@localhost bin]# vi /etc/systemd/system/redis.service

Copy and paste 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 as its own path.

Set up boot up

[root@localhost bin]# systemctl daemon-reload[root@localhost bin]# systemctl start redis.service[root@localhost bin]# systemctl enable redis.service

Create redis command soft link

[root@localhost ~]# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis

Testing redis

service operation command

systemctl start redis.service #Start redis service systemctl stop redis.service #stop redis service systemctl restart redis.service #Restart service systemctl status redis.service #View current status of services systemctl enable redis.service #Set boot auto-start systemctl disable redis.service #Stop booting and start reading here, this article "centos7 how to install redis" has been introduced, want to master the knowledge points of this article also need to be used by yourself to understand, if you want to know more related content of the article, welcome to pay attention to the industry information channel.

Tags: Services directories content commands articles background proper foreground ideas files new knowledge more steps source code status environment knowledge knowledge points articles details Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Redmi Shulou Technology Docker