PHP Redis Session Handler – WordPress Redis

Redis is an open source key-value cache and storage system, also referred to as a data structure server for its advanced support for several data types, such as hashes, lists, sets, and bitmaps, amongst others. It also supports clustering, which makes it often used for highly-available and scalable environments.

In this tutorial, we’ll see how to install and configure an external Redis server to be used as a session handler for a PHP application running on CentOS 8.

The session handler is responsible for storing and retrieving data saved into sessions – by default, PHP uses files for that. An external session handler can be used for creating scalable PHP environments behind a load balancer, where all application nodes will connect to a central server to share session information.

How to Set Up a Redis Server as a Session Handler:

# nano /usr/local/php74/lib/php.ini
# session.save_handler = redis
# session.save_path = "tcp://127.0.0.1:6379?auth=secretpass123"

Redis Extra Security:

Set a Password for the Redis Server

To add an extra layer of security to your Redis installation, you are encouraged to set a password for accessing the server data. We will edit the same configuration file from the previous step, /etc/redis/redis.conf:

sudo nano /etc/redis/redis.conf

 Copy

Now, uncomment the line that contains requirepass, and set a strong password:/etc/redis/redis.conf

requirepass yourverycomplexpasswordhere

 Copy

Restart the Redis service so the changes take effect:

sudo service redis-server restart

PHP, Redis, Session, Wordpress


Vincent Verloop

Ervaren ICT Professional met een bewezen geschiedenis van werken in de IT. Begonnen in eigen computer werkplaats, daarna aan het werk gegaan bij KPN als technische helpdeskmedewerker. Daarna Ziggo monteur. Daarna systeembeheerder bij Rijksdienst voor Wegverkeer. Daarna Zelfstandig Ondernemer. Daarna Sport Computer Graphics. Daarna T-Mobile/Tele2. Daarna Centric. Bekwaam in OS X, Search Engine Optimization (SEO), PHP, WordPress en Domain Name System (DNS). Sterke media- en communicatieprofessional met een diploma MBO niveau 4 gericht op ICT-beheer / ICT-beheerder. Volg Vincent Verloop op Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *

BLIJF OP DE HOOGTE
Schrijf u in voor onze gratis nieuwsbrief


© Vincent Verloop. All rights reserved. Powered by Verloophosting.