To install Redis on Ubuntu 22.04, you can follow these steps:
-
Update system packages:
sudo apt update ```
-
Install Redis:
sudo apt install redis-server ```
-
After the installation is complete, the Redis service will start automatically. You can check the status of the Redis service using the following command:
sudo systemctl status redis-server ``` 如果服务正在运行,你将看到类似以下内容的输出:
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running)… -
Optional: Configure Redis (as needed):
- Enter the Redis configuration file directory:
cd /etc/redis
- Open
redis.conf
the file for editing:sudo nano redis.conf
- Modify the parameters in the configuration file according to your needs. For example, you can change the IP address, port number, and other options that Redis listens on. When finished, save and close the file.
- Enter the Redis configuration file directory:
-
Optional: Restart the Redis service (if you made configuration changes):
sudo systemctl restart redis-server ```
Now, Redis has been successfully installed on Ubuntu 22.04. You can use Redis's command line interface (redis-cli) or a programming language library that interacts with Redis for operation and management.