ubuntu, debian install redis, set the startup auto start and password, and allow Internet access

Keywords: Operation & Maintenance Redis Python encoding SSL

The package of apt comes with redis. If the version of redis is not very high, you can directly use apt to install it:

apt install redis-server

Start redis:

redis-server

Start command line interface:

redis-cli

Note: after apt installation, the location of redis configuration file is / etc/redis/redis.conf
To modify a profile:

nano /etc/redis/redis.conf

After this line is commented out, the Internet can access:

#bind 127.0.0.1 ::1

redis installed by apt is started in the background by default:

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

Set password:

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass test

Connection test on Python 3;

pip3 install redis
python3:

The parameters of redis.Redis are as follows:

__init__(self, host='localhost', port=6379, db=0, password=None, socket_timeout=None, socket_connect_timeout=None, socket_keepalive=None, socket_ke
epalive_options=None, connection_pool=None, unix_socket_path=None, encoding='utf-8', encoding_errors='strict', charset=None, errors=None, decode_respon
ses=False, retry_on_timeout=False, ssl=False, ssl_keyfile=None, ssl_certfile=None, ssl_cert_reqs='required', ssl_ca_certs=None, max_connections=None)

Posted by ElkySS on Sun, 01 Dec 2019 17:59:17 -0800