Home > Database > Redis > How to install redis on centos7

How to install redis on centos7

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-06-02 17:20:58
forward
1851 people have browsed it

1. Install gcc dependencies

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

 [root@localhost local]# yum install -y gcc
Copy after login

2. Download and decompress the installation package

[root@localhost local]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz

[root@localhost local]# tar -zxvf redis-5.0.3.tar.gz
Copy after login

3. cd to the redis decompression directory and execute compilation

[root@localhost local]# cd redis-5.0.3

[root@localhost redis-5.0.3]# make
Copy after login

4. Install and specify the installation directory

[root@localhost redis-5.0.3]# make install PREFIX=/usr/local/redis
Copy after login

5. Start the service

5.1 Foreground startup

[root@localhost redis-5.0.3]# cd /usr/local/redis/bin/

[root@localhost bin]# ./redis-server
Copy after login

5.2 Background startup

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

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

Modify the redis.conf file and change daemonize no to daemonize yes

[root@localhost bin]# vi redis.conf
Copy after login

Background startup

[root@localhost bin]# ./redis-server redis.conf
Copy after login

6. Set boot startup

Add boot startup service

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

Copy and paste the following content:

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Copy after login

Note: ExecStart is configured to its own path

Set up for startup

[root@localhost bin]# systemctl daemon-reload

[root@localhost bin]# systemctl start redis.service

[root@localhost bin]# systemctl enable redis.service
Copy after login

Create a redis command soft link

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

Test redis

Service operation command

systemctl start redis.service   #启动redis服务

systemctl stop redis.service   #停止redis服务

systemctl restart redis.service   #重新启动服务

systemctl status redis.service   #查看服务当前状态

systemctl enable redis.service   #设置开机自启动

systemctl disable redis.service   #停止开机自启动
Copy after login

The above is the detailed content of How to install redis on centos7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php redis connection problem
From 1970-01-01 08:00:00
0
0
0
About a small error in the redis manual
From 1970-01-01 08:00:00
0
0
0
python2.7 - django cannot connect to redis
From 1970-01-01 08:00:00
0
0
0
I can't connect to redis using php
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template