Redis database (cache and sessions)
Install Redis to speed up your web applications via caching.
What this tutorial does
The tutorial "Redis database (cache and sessions)" helps you achieve this goal:
Install Redis to speed up your web applications via caching.
Debian/Ubuntu
-
Install Redis: apt install -y redis-server -
Start and activate: systemctl enable --now redis-server - --- Secure Redis ---
- Edit /etc/redis/redis.conf:
- bind 127.0.0.1 (listen only locally)
- requirepass strong_password (enable password)
-
Restart Redis: systemctl restart redis-server - --- Test Redis ---
- redis-cli
- AUTH strong_password
- SET test "hello"
- GET test (doit retourner "hello")
-
--- Use Redis for PHP sessions --- -
Install PHP extension: apt install -y php-redis -
In php.ini, add: - session.save_handler = redis
- session.save_path = "tcp://127.0.0.1:6379?auth=strong_password"
-
Restart Apache: systemctl restart apache2