Home >Database >Redis >How to install and configure redis in CentOS

How to install and configure redis in CentOS

王林
王林forward
2023-05-27 16:13:121336browse

1. Download

Refer to the operation guide provided by the redis official website. The official website address is https://redis.io/download. There are download and installation methods at the bottom.

Create directory to download the compressed package

wget https://download.redis.io/releases/redis-6.2.4.tar.gz

Decompression
tar There is a redis description file "README.md", you have time to learn about it)

cd redis-6.2.4

1. Compile
make

Compilation is successful and the service is started directly for verification.
Note

: If the compilation tool is not installed, an error will be reported. You need to install the compilation tool and delete the error file generated by redis compilation. How to install compilation tools

yum install gcc

Delete

make distclean

2. Verification Compile

Go to the "src" directory and run the "redis-server" file

cd src

##./redis-server

3. Set up system startup

1. Install redisThe path can be customized. If the "PREFIX" parameter is not carried, redis will be installed in "/usr/ local/bin" directory.

make install PREFIX=/opt/xxx/redis

2. Set environment variables

##vi / etc/profile

Append environment variables at the end, the directory is the same as the directory where redis is installed.

export REDIS_HONE=/opt/xxx/redisexport PATH=$PATH:$REDIS_HOME/bin

Enable Environment variables take effect

source /etc/profile

How to install and configure redis in CentOS

3. Create a redis instance

A server can create multiple redis processes with different port numbers .

Enter the "utils" directory (in the decompressed redis directory).

Use the script file provided by redis to create a redis instance

cd utils

./install_server.shHow to install and configure redis in CentOS

Note:

The following errors can be solved by modifying the "install_server.sh" file.

vi install_server.sh

Comment out the following area (version 6.2.4, around line 76)How to install and configure redis in CentOS

The instance is created successfully, and the information corresponding to the instance can be seen in the corresponding directory. Multiple instances can be created, but the port numbers cannot be the same.

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

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete