Home >Backend Development >PHP Tutorial >session sharing
1.memcached configuration: (v1.4.13)
Node 1 (192.168.159.131:11444)
Node 2 (192.168.159.131:11333)
2.tomcat configuration
tomcat1 (192.168.159.128:8081)
tomcat2 (192.168.159.128:8082)
3.nginx is installed at 192.168.159.131.
Method 1: Configure in server.xml.
Find the host node and add
Method 2: Configure in context.xml.
Find the Context node and add
Finally, put your application into two tomcats, and start memcached, tomcat, and nginx in sequence. Access your nginx and you will find that the sessions in the two tomcats can remain shared.
1.redis configuration (192.168.159.131:16300) (v2.8.3)
2.tomcat configuration
tomcat1( 192.168.159.130:8081)
tomcat2 (192.168.159.130:8082)
3.nginx is installed at 192.168.159.131.
First, configure tomcat so that it saves the session to redis. There are two methods, which are also configured in server.xml or context.xml. The difference is that memcached only needs to add a manager tag, while redis needs to add the following content: (Note: the valve tag must be in front of the manager.)
Secondly, configure nginx to keep the test session shared.
Finally, put your application into two tomcats, and start redis, tomcat, and nginx in sequence. Access your nginx and you will find that the sessions in the two tomcats can remain shared.
The above has introduced session sharing, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.