0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Laravel Phpredis インストール

Posted at

目的

  • Laravelのセッションとキャッシュにredisを使う

Phpredisインストール

// 作業ディレクトリに移動
# cd

// phpredisのソース取得
# dnf install php-devel
# git clone https://github.com/nicolasff/phpredis.git

// phpredis コンパイル
# cd phpredis
# phpize
# ./configure
# make
# make install
	Installing shared extensions:     /usr/lib64/php/modules/
# ls -l /usr/lib64/php/modules/redis.so
	-rwxr-xr-x 1 root root 2576456 Nov  7 18:28 /usr/lib64/php/modules/redis.so

// phpredisをapacheのモジュールとして動かす
# vi /etc/php.d/20-redis.ini
	extension=redis.so
	(ZZ)
# systemctl restart httpd

// 不要となったディレクトリを削除
# cd ../
# rm -rf ./phpredis/

laravel設定(要検証)

config/database.php
'redis' => [
    'client' => env('REDIS_CLIENT', 'phpredis'),
    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'redis'),
    ],
    'clusters' => [
        'default' => [
            [
                'host' => '192.158.11.10',
                'password' => null,
                'port' => 7000,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            [
                'host' => '192.158.11.10',
                'password' => null,
                'port' => 7001,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            [
                'host' => '192.158.11.11',
                'password' => null,
                'port' => 7001,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            ...
        ],
        'cache' => [
            [
                'host' => '192.158.11.10',
                'password' => null,
                'port' => 7000,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            [
                'host' => '192.158.11.10',
                'password' => null,
                'port' => 7001,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            [
                'host' => '192.158.11.11',
                'password' => null,
                'port' => 7001,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            ...
        ],
        'session' => [
            [
                'host' => '192.158.11.10',
                'password' => null,
                'port' => 7000,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            [
                'host' => '192.158.11.10',
                'password' => null,
                'port' => 7001,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            [
                'host' => '192.158.11.11',
                'password' => null,
                'port' => 7001,
                'database' => 0,
                'read_write_timeout' => env('REDIS_READ_WRITE_TIMEOUT', 60),
            ],
            ...
        ],
    ],
],
.env
SESSION_DRIVER=redis
CACHE_STORE=redis
REDIS_CLIENT=phpredis
REDIS_CLUSTER=redis
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?