Redis Shared Session Details

Source: Internet
Author: User
Tags php server redis server
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

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.