LoginSignup
5
5

More than 5 years have passed since last update.

CentOS7にRedisをインストールする

Last updated at Posted at 2018-12-26

CentOS7 に Redis をインストールする

CentOS7にRedisをインストールしてPHPから使えるようにする。

epelリポジトリをインストールする。

# yum install epel-release

yumコマンドを実行するたびにepelを参照するのでepelを無効にして、必要なときだけ使用するように設定を変更する。

/etc/yum.repos.d/epel.repo
[epel]
enabled=0

epelリポジトリを使用するときはyum <コマンド> <パッケージ名> --enablerepo=epelでコマンドを実行する。
Redisをインストールしたいので、epelリポジトリを指定してredisをインストールする。

# yum install redis --enablerepo=epel

Redisの設定を変更する
メモリがいっぱいになったときに、有効期限が設定されたキーの中でより短い有効期間(TTL)のキーを削除するmaxmemory-policy volatile-ttlを指定する。

/etc/redis.conf
maxmemory 256m
maxmemory-policy volatile-ttl

Redisのサービスを有効にして起動する。

# systemctl enable redis.service
# systemctl start redis.service

PHPのRedisクライアントモジュールをインストールする。

# yum install php-pecl-redis --enablerepo=epel

すべてのインストールが完了したらApacheを再起動して、redisが読み込まれているかを確認する。

# systemctl restart httpd.service
# php -m | grep redis
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5