This time to everyone to bring Redis shared session details, Redis shared session of the attention of what, the following is the actual case, together to see.
First, when the system's traffic increases, using Redis to save the session can improve the performance of the system, but also convenient for multi-machine load when sharing session
1. Open config/database.php. Increase the session connection in Redis
' Session ' = = [ ' host ' + env (' redis_host ', ' 127.0.0.1 '), ' password ' = env (' Redis_password ', null), ' Port ' = env (' Redis_port ', 6379), ' database ' = [ ],
2. Open the config/session.php and fill in the Redis connection above
'connection' => 'session',
3. Modify env to use Redis access Sessoin
SESSION_DRIVER=redis
Now access the system. The session has been saved using Redis. Approx. 15% performance improvement (current project)
Second, Redis access configuration, in order to use other servers can access to Redis need to configure Redis remote access
1. Open/etc/redis.conf To modify bind information, such as the current server LAN IP is 10.0.0.2
bind 127.0.0.1 10.0.0.2
2. Modify Protected-mode
protected-mode no
3. Reload the Redis configuration
service redis-server reload
4. Register to check if the iptable is open with 6379 port access
iptables -I INPUT -s 10.0.0.2 -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT
5. Other servers Modify Env
REDIS_HOST=10.0.0.2
Other servers now have access to the Redis server.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
PHP Custom two-dimensional array sorting function array
PHP server-side API and interface development detailed