Home > Database > Redis > body text

How to install and configure redis in Ubuntu

WBOY
Release: 2023-05-30 17:31:06
forward
1603 people have browsed it

Use the command line to update all software packages

sudo apt-get update
###### 在Linux Ubuntu中安装Redis数据库

```LINUX
#安装Redis服务器端
~ sudo apt-get install redis-server
Copy after login

After the installation is completed, the Redis server will start automatically. We check the Redis server program

# 检查Redis服务器系统进程
~ ps -aux|grep redis
redis     4162  0.1  0.0  10676  1420 ?        Ss   23:24   0:00 /usr/bin/redis-server /etc/redis/redis.conf
conan     4172  0.0  0.0  11064   924 pts/0    S+   23:26   0:00 grep --color=auto redis

# 通过启动命令检查Redis服务器状态
~ netstat -nlt|grep 6379
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN

# 通过启动命令检查Redis服务器状态
~ sudo /etc/init.d/redis-server status
redis-server is running
Copy after login
Access Redis through the command line client

Installing the Redis server will automatically install the Redis command line client program.
Enter the redis-cli command on the local machine to start, and the client program accesses the Redis server.

~ redis-cli
redis 127.0.0.1:6379>

# 命令行的帮助
redis 127.0.0.1:6379> help
redis-cli 2.2.12
Type: "help @" to get a list of commands in 
      "help " for help on 
      "help " to get a list of possible help topics
      "quit" to exit


# 查看所有的key列表
redis 127.0.0.1:6379> keys *
(empty list or set)
Copy after login
Modify Redis configuration

By default, no password is required to access the Redis server. In order to increase security, we need to set the access password of the Redis server. Set the access password to redisredis.

  • Use vi to open the configuration file redis.conf of the Redis server

~ sudo vi /etc/redis/redis.conf

#取消注释requirepass
requirepass redisredis
Copy after login
Let the Redis server be accessed remotely
~ sudo vi /etc/redis/redis.conf

#注释bind
#bind 127.0.0.1
Copy after login
Modify After that, restart the Redis server.
~ sudo /etc/init.d/redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server.
Copy after login
  • We check the network listening port of Redis

检查Redis服务器占用端口
~ netstat -nlt|grep 6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN
Copy after login

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

Related labels:
source:yisu.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template