nginx+tomcat+redis
程序员文章站
2022-07-04 22:38:43
...
1.下载相关的jar,放入到Tomcat的lib目录下
https://github.com/jcoleman/tomcat-redis-session-manager/downloads tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar(根据服务器配置选择)
https://github.com/xetorthio/jedis/downloads jedis-2.1.0.jar
http://commons.apache.org/proper/commons-pool/download_pool.cgi commons-pool-1.6.jar
2. 在tomcat的conf目录下context.xml中加入如下内容
<Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" /> <Manager className="com.radiadesign.catalina.session.RedisSessionManager" host="localhost" <!-- optional: defaults to "localhost" --> port="6379" <!-- optional: defaults to "6379" --> database="0" <!-- optional: defaults to "0" --> maxInactiveInterval="60" <!-- optional: defaults to "60" (in seconds) --> />
3.配置nginx
upstream tomcat{ server localhost:8080 weight=5; server localhost:9080 weight=5; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; proxy_pass http://tomcat; }
4.启动nginx,redis,tomcat即可