MirrorNest
← すべてのガイド

Redis on Ubuntu

A free, open-source, in-memory key-value store used as a cache, session store, or message broker by countless self-hosted apps -- installed from Ubuntu's package repository.

対象: Ubuntu 22.04 LTS / 24.04 LTSDatabase公式ホームページ ↗公式ドキュメント ↗
このガイドは上記リンク先にあるRedis on Ubuntu公式ドキュメントをもとに作成されています。ディストリビューションやプロジェクトのバージョンは時間とともに変わるため、本番サーバーでこれらのコマンドを実行する前に、必ず公式ドキュメントで正確なパッケージ名・バージョン名を確認してください。
  1. 1Install Redis

    sudo apt update
    sudo apt install redis-server
  2. 2Enable it to run as a proper background service

    Ubuntu's package defaults to supervised mode off -- switch it to systemd so it starts on boot and restarts on crash correctly.

    sudo sed -i 's/supervised no/supervised systemd/' /etc/redis/redis.conf
    sudo systemctl restart redis.service
  3. 3Set a password if anything other than localhost can reach it

    Redis has no authentication by default -- fine for a service only reachable from localhost, a real risk if the port is exposed to the network.

    # In /etc/redis/redis.conf, uncomment and set: # requirepass a-real-password
    sudo systemctl restart redis.service
  4. 4Verify it's running

    Should return PONG.

    redis-cli ping