1. Prepare the required installation package and JAR package
Nginx-1.6.3.tar.gz
Apache-tomcat-7.0.62.tar.gz
Redis-3.0.2.tar.gz
Jdk-7u79-linux-x64.tar.gz
Jedis-2.1.0.jar
Commons-pool-1.6.jar
Tomcat-redis-session-manager-tomcat-7.jar
Description: The Jedis version used here is 2.1.0,commons-pool to 1.6,
There are many places on the net jedis2.6 above, commons-pool2.0 version, will appear class not found error, is due to commons-pool2.0 version of the missing Commons/pool/impl folder.
2.tomcat Configuration
Join Tomcat's session management in Context.xml
Redis key value time-out
3.nginx Configuration
Upstream tomcat{
Server 127.0.0.1:18099;
Server 127.0.0.1:18098;
}
Server
{
Listen 80;
server_name www.myserver.com;
Index maomingindex.do index.do index.jsp index.html;
Location/{
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $remote _addr;
Client_max_body_size 10m;
Client_body_buffer_size 128k;
Proxy_connect_timeout 5;//here time according to the actual situation of application configuration
Proxy_send_timeout 5;//Too short will lead to bad Gateway error
Proxy_read_timeout 5;//too long can cause tomcat downtime to switch slowly
Proxy_buffer_size 4k;
Proxy_buffers 4 32k;
Proxy_busy_buffers_size 64k;
Proxy_temp_file_write_size 64k;
Proxy_pass Http://tomcat;
}
Rewrite_log off;
}
4. The corresponding jar package and relevant download address are attached here.
Tomcat-redis-session Source Address: https://github.com/jcoleman/tomcat-redis-session-manager/downloads
Jedis Source Address: Https://github.com/xetorthio/jedis
The above describes the Nginx+tomcat7+redis cluster configuration, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.