How to configure a PHP session to use a Redis cluster

Source: Internet
Author: User
Tags php session redis cluster

This example is based on Phpredis 2.2.8, supports cluster processing, php5.3 and above.

1, Page modification:
Ini_set (' Session.save_handler ', ' rediscluster ');
Ini_set (' Session.save_path ', ' Seed[]=192.168.100.1:7000&seed[]=192.168.100.1:7001&timeout=3&read_ Timeout=3 ');

2, modify the php.ini

; Session.save_handler = Files

; Session.save_path = "/var/lib/php/session"

Note the above two lines, add the following two lines:
Session.save_handler = Rediscluster

Session.save_path = "Seed[]=192.168.100.1:7000&seed[]=192.168.100.1:7001&timeout=3&read_timeout=3"

3, PHP-FPM configuration, modify FPM configuration file www.conf (this profile name is not necessarily this, according to the actual situation modified)

;p Hp_value[session.save_handler] = files
;p Hp_value[session.save_path] =/var/lib/php/session

Note the above two lines and add the following:

Php_value[session.save_handler] = Rediscluster

Php_value[session.save_path] = "Seed[]=192.168.100.1:7000&seed[]=192.168.100.1:7001&timeout=3&read_ Timeout=3 "

  Restart PHP-FPM after modification

Website address: Https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#readme

How to configure a PHP session to use a Redis cluster

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.