Installation and calibration

Direct input command

sudo apt-get install redis-server
Copy the code

When the installation is complete, the Redis server will start automatically. Use the following command:

ps -aux|grep redis
Copy the code

You can see the server system process default port 6379:

Redis 2890 0.2 0.1 41872 6064? Ssl 14:17 0:07 /usr/bin/redis-server 127.0.0.1:6379 hzlarm 3222 0.0 0.0 11324 780 PTS /2 S+ 15:02 0:00 grep --color=auto redisCopy the code

Use the following command:

netstat -nlt|grep 6379
Copy the code

You can see the redis server status:

TCP 0 0 127.0.0.1:6379 0.0.0.0:* LISTENCopy the code


sudo /etc/init.d/redis-server status
Copy the code

Redis server basic configuration

Configuration file is/etc/redis/redis conf (online installation recommended) or/usr/local/redis/redis conf (manual installation)

First of all,

sudo vi /etc/redis/redis.conf
Copy the code

Add a Redis access account. The Redis server does not require a password by default. Assume that the password is hzlarm. Remove the requirePass comment # and add the password after it

requirepass hzlarm
Copy the code

Enable Redis remote connection and comment out binding address

# bind 127.0.0.1Copy the code

After the configuration, restart the server

sudo /etc/init.d/redis-server restart or
sudo service redis-server restart or
sudo redis-server /etc/redis/redis.conf
Copy the code