{"id":60,"date":"2026-04-05T20:22:49","date_gmt":"2026-04-05T12:22:49","guid":{"rendered":"http:\/\/43.136.56.131\/?p=60"},"modified":"2026-04-05T20:22:49","modified_gmt":"2026-04-05T12:22:49","slug":"nginxtomcat%e9%9b%86%e7%be%a4redis%e5%85%b1%e4%ba%absession%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/mm1.asia\/index.php\/2026\/04\/05\/nginxtomcat%e9%9b%86%e7%be%a4redis%e5%85%b1%e4%ba%absession%e6%96%b9%e6%a1%88\/","title":{"rendered":"Nginx+Tomcat\u96c6\u7fa4Redis\u5171\u4eabsession\u65b9\u6848"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u5206\u5e03\u5f0fSession\u5171\u4eab\u65b9\u6848\u7684\u7531\u6765<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u65f6\u5019\uff0c\u670d\u52a1\u5668\u628a\u5ba2\u6237\u7aef\u4fe1\u606f\u4ee5\u67d0\u79cd\u5f62\u5f0f\u8bb0\u5f55\u5728\u670d\u52a1\u5668\u4e0a\uff0c\u8fd9\u5c31\u662f Session\u3002\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u518d\u6b21\u8bbf\u95ee\u65f6\u53ea\u9700\u8981\u4ece\u8be5 Session \u4e2d\u67e5\u627e\u8be5\u5ba2\u6237\u7684\u72b6\u6001\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u6211\u4eec\u5efa\u8bae\u4f7f\u7528\u5916\u90e8\u7684\u7f13\u5b58\u8bbe\u5907\u6765\u5171\u4eab Session\uff0c\u907f\u514d\u5355\u4e2a\u670d\u52a1\u5668\u8282\u70b9\u6302\u6389\u800c\u5f71\u54cd\u670d\u52a1\uff0c\u5171\u4eab\u6570\u636e\u90fd\u4f1a\u653e\u5230\u5916\u90e8\u7f13\u5b58\u5bb9\u5668\u4e2d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528Redis\u5b9e\u73b0\u5171\u4eabsession\uff0c\u6240\u6709\u670d\u52a1\u5668\u7684session\u4fe1\u606f\u90fd\u5b58\u50a8\u5230\u4e86\u540c\u4e00\u4e2aRedis\u96c6\u7fa4\u4e2d\uff0c\u5373\u6240\u6709\u7684\u670d\u52a1\u90fd\u5c06 Session \u7684\u4fe1\u606f\u5b58\u50a8\u5230 Redis \u96c6\u7fa4\u4e2d\uff0c\u65e0\u8bba\u662f\u5bf9 Session \u7684\u6ce8\u9500\u3001\u66f4\u65b0\u90fd\u4f1a\u540c\u6b65\u5230\u96c6\u7fa4\u4e2d\uff0c\u8fbe\u5230\u4e86 Session \u5171\u4eab\u7684\u76ee\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cookie\u662f\u670d\u52a1\u5668\u5199\u7ed9\u5ba2\u6237\u7aef\u7684\u6587\u4ef6\uff0c\u4e5f\u53ef\u4ee5\u79f0\u4e3a\u6d4f\u89c8\u5668\u7f13\u5b58\u3002\u4fdd\u5b58\u5728\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u4e2d\uff0c\u800c Session \u4fdd\u5b58\u5728\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u5e38\u89c1\u7684session\u96c6\u7fa4\u65b9\u6848<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f20\u7edf\u7684session\u7531\u670d\u52a1\u5668\u7aef\u751f\u6210\u5e76\u5b58\u50a8\uff0c\u5f53\u5e94\u7528\u8fdb\u884c\u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u65f6\u5019\uff0c\u5982\u4f55\u4fdd\u8bc1\u4e0d\u540c\u670d\u52a1\u5668\u4e0asession\u4fe1\u606f\u80fd\u591f\u5171\u4eab\u5462\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1.\u4e0d\u540c\u670d\u52a1\u5668\u4e0asession\u6570\u636e\u8fdb\u884c\u590d\u5236<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2.session\u96c6\u4e2d\u5b58\u50a8(session\u5171\u4eab)\uff08redis\uff0cmemcached\uff0chbase\u7b49\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e24\u79cd\u65b9\u5f0f\u7684\u4f18\u7f3a\u70b9\uff0c\u4e00\u76ee\u4e86\u7136.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Session\u590d\u5236<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u662f\u6307session\u4fe1\u606f\u4f1a\u5728\u96c6\u7fa4\u8282\u70b9\u4e4b\u95f4\u590d\u5236\uff0c\u6bcf\u4e2a\u8282\u70b9\u670d\u52a1\u5668\u4e0a\u90fd\u4f1a\u6709\u76f8\u540c\u7684session\u4fe1\u606f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f18\u70b9: \u662f\u5373\u4f7f\u4e00\u4e2a\u8282\u70b9\u670d\u52a1\u5668\u5b95\u673a\u4e86\uff0c\u53ea\u8981\u8fd8\u6709\u670d\u52a1\u5668\u5b58\u6d3b\uff0c\u5c31\u4e0d\u5f71\u54cd\u7528\u6237\u4f7f\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f3a\u70b9: \u7f3a\u70b9\u662fnode\u4e4b\u95f4\u901a\u4fe1\u9891\u7e41\uff0c\u54cd\u5e94\u901f\u5ea6\u6709\u5f71\u54cd\uff0c\u591a\u5e76\u53d1\u3001\u9ad8\u9891\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\u6027\u80fd\u4e0b\u964d\u6bd4\u8f83\u5389\u5bb3\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Session\u5171\u4eab<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u57fa\u4e8eMemcache\/Redis\u7b49\u6570\u636e\u5e93\u7684session\u5171\u4eab\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">tomcat\u81ea\u5e26\u96c6\u7fa4\u4e2d\uff0c\u63d0\u4f9b\u4e86session\u590d\u5236\uff0csession\u4fe1\u606f\u4f1a\u5728\u5404\u4e2atomcat\u4e2d\u540c\u6b65\uff0c\u5bf9\u7f51\u7edc\u8981\u6c42\u8f83\u9ad8\uff0csession\u5185\u5b58\u6d88\u8017\u5f71\u54cd\u4f1a\u5f88\u5927,\u5bf9\u4e8e\u5c0f\u96c6\u7fa4\u591f\u7528\u4e86\uff0c\u5927\u96c6\u7fa4\u8fd8\u662f\u5efa\u8bae\u4f7f\u7528redis\u6216\u8005memcache\u8fdb\u884csession\u5171\u4eab\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56e0\u6b64\uff0c\u6784\u5efatomcat\u96c6\u7fa4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528tomcat\u57fa\u4e8eredis\u7684session\u5171\u4eab\u673a\u5236\u3002\u800c\u5728\u901a\u8fc7nginx\u6784\u5efa\u96c6\u7fa4\u65f6\uff0c\u4e5f\u6d89\u53casession\u7684\u95ee\u9898.\u5982\u4e0b\u56fe\u6240\u793a\u67b6\u6784:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-5-1024x343.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"343\" data-original=\"http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-5-1024x343.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-63\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728nginx\u7684\u96c6\u7fa4\u67b6\u6784\u4e0b,\u53ef\u6839\u636e\u8bbe\u7f6e\u7684nginx\u8d1f\u8f7d\u5747\u8861\u7b97\u6cd5\u7684\u4e0d\u540c\uff0csession\u7684\u5b9e\u73b0\u673a\u5236\u4e5f\u4e0d\u76f8\u540c\uff0c\u4f8b\u5982\u8f6e\u8be2\uff08\u9ed8\u8ba4\uff09\uff0c\u6307\u5b9a\u6743\u91cd\uff0cfair\uff08\u7b2c\u4e09\u65b9\uff09\uff0curl_hash\uff08\u7b2c\u4e09\u65b9\uff09\u8d1f\u8f7d\u7b97\u6cd5\u65f6\uff0c\u96c6\u7fa4\u5404\u4e2a\u8282\u70b9\u4e4b\u95f4\u5fc5\u987b\u901a\u8fc7session\u5171\u4eab\u6765\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u907f\u5f00session\u95ee\u9898,\u53ef\u4ee5\u4f7f\u7528nginx\u7684ip_hash\u7b97\u6cd5\uff0c\u6b64\u7b97\u6cd5\u5c06\u7528\u6237\u7684\u8bf7\u6c42\u7edf\u4e00\u53d1\u9001\u5230\u540c\u4e00\u4e2a\u8282\u70b9\u670d\u52a1\u5668\u4e0a\uff0c\u5982\u4e0d\u8003\u8651\u8282\u70b9\u670d\u52a1\u5668\u5b95\u673a\u7684\u60c5\u51b5\uff0c\u53ef\u4e0d\u8003\u8651session\u95ee\u9898\u3002\u4f46\u662f\uff0c\u8282\u70b9\u670d\u52a1\u5668\u5b95\u673a\u540e\uff0c\u7528\u6237\u9700\u8981\u5173\u6389\u6d4f\u89c8\u5668\u4ece\u65b0\u6253\u5f00\u767b\u5f55\u624d\u80fd\u6062\u590d\u6b63\u5e38\uff0c\u8fd9\u6837\u4f53\u9a8c\u4f1a\u53d8\u5f97\u5f88\u5dee\u3002\u56e0\u6b64\uff0csession\u5171\u4eab\u5728\u96c6\u7fa4\u67b6\u6784\u4e2d\u6709\u5f88\u5927\u7684\u7528\u9014\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u5e94\u7528\u73af\u5883\u4ecb\u7ecd<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001session\u5e94\u7528\u5de5\u5177<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u7531\u4e8e\u5ba2\u6237\u8981\u4f7f\u7528Tomcat\u96c6\u7fa4\uff0c\u56e0\u6b64\uff0c\u9700\u8981\u89e3\u51b3session\u5171\u4eab\u7684\u95ee\u9898\u3002\u5728\u7f51\u4e0a\u6709\u5f88\u591a\u89e3\u51b3\u65b9\u6848\uff0c\u6bd4\u5982\u901a\u8fc7Memcached\u6765\u5b9e\u73b0\uff0c\u901a\u8fc7Redis\u6765\u5b9e\u73b0\u7684\uff0c\u76f8\u4fe1\u5f88\u591a\u540c\u5b66\u90fd\u662f\u901a\u8fc7jcoleman\uff08<a href=\"https:\/\/github.com\/jcoleman\/tomcat-redis-session-manager\">https:\/\/github.com\/jcoleman\/tomcat-redis-session-manager<\/a>\uff09 \u7684redis\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u662f\u6b64\u65b9\u6848\u4ec5\u652f\u6301tomcat6\u548c7\uff0c\u8981\u652f\u6301tomcat8\u62169\u9700\u8981\u4fee\u6539\u4ee3\u7801\uff0c\u7136\u540e\u6253\u5305\u90e8\u7f72\uff0c\u975e\u5e38\u9ebb\u70e6\u3002\u56e0\u6b64\u5f3a\u70c8\u4e0d\u63a8\u8350\u6b64\u79cd\u65b9\u6848\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8fd9\u91cc\u4e3b\u8981\u4ecb\u7ecd\u53e6\u4e00\u4e2a\u66f4\u4e3a\u7b80\u5355\u7684\u65b9\u6848\uff1aredisson\uff0c\u652f\u6301\u6700\u65b0\u7684JDK\u548c\u5404\u4e2a\u7248\u672c\u7684tomcat\uff086\/7\/8\/9\/10\uff09\uff0c\u5b98\u7f51\uff1a<a href=\"https:\/\/redisson.org\/\">https:\/\/redisson.org\/<\/a> \u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">redisson\u662fredis\u5b98\u7f51\u63a8\u8350\u7684java\u8bed\u8a00\u5b9e\u73b0\u5206\u5e03\u5f0f\u9501\u7684\u9879\u76ee\u3002\u5f53\u7136\uff0credisson\u8fdc\u4e0d\u6b62\u5206\u5e03\u5f0f\u9501\uff0c\u8fd8\u5305\u62ec\u5176\u4ed6\u4e00\u4e9b\u5206\u5e03\u5f0f\u7ed3\u6784\u3002\u4f8b\u5982\uff0c\u5206\u5e03\u5f0f\u5e94\u7528\uff0c\u5206\u5e03\u5f0f\u7f13\u5b58\uff0c\u5206\u5e03\u5f0f\u56de\u8bdd\u7ba1\u7406\uff0c\u5206\u5e03\u5f0f\u670d\u52a1\uff08\u4efb\u52a1\uff0c\u5ef6\u8fdf\u4efb\u52a1\uff0c\u6267\u884c\u5668\uff09\uff0c\u5206\u5e03\u5f0fredis\u5ba2\u6237\u7aef\u7b49\u3002\u800c\u6211\u4eec\u8fd9\u91cc\u8981\u4f7f\u7528\u7684\u662fredisson\u63d0\u4f9b\u7684Tomcat Session Manager\u529f\u80fd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tomcat session\u5171\u4eab\u7684github\u5730\u5740\u4e3a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/github.com\/redisson\/redisson\/tree\/master\/redisson-tomcat\n<\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2\u3001\u73af\u5883\u51c6\u5907<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u8bf4\u660e\u4e0b\u6b64\u6848\u4f8b\u7684\u5e94\u7528\u73af\u5883\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u4e09\u53f0\u7269\u7406\u673a\u6216\u865a\u62df\u673a\uff0c\u4f7f\u7528RHEL9\/Almalinux9.1\u7cfb\u7edf\uff08172.16.213.28\u3001172.16.213.29\u3001172.16.213.30\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff082\uff09redis7.x\u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff083\uff09JDK1.8\u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff084\uff09tomcat9.x\u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\uff085\uff09nginx1.23\u7248\u672c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\uff0c172.16.213.28\u670d\u52a1\u5668\u5b89\u88c5redis\u548ctomcat1\uff0c172.16.213.29\u5b89\u88c5tomcat2.\uff0c172.16.213.30\u5b89\u88c5nginx\uff0c\u901a\u8fc7nginx\u7684\u8d1f\u8f7d\u5747\u8861\u529f\u80fd\uff0c\u5b9e\u73b0tomcat1\u548ctomcat2\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u8fdb\u800c\u5224\u65ad\u4e24\u4e2atomcat\u5b9e\u4f8b\u662f\u5426\u5b9e\u73b0\u4e86session\u5171\u4eab\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001nginx+tomcat+redis\u90e8\u7f72\u8fc7\u7a0b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6574\u4e2a\u90e8\u7f72\u8fc7\u7a0b\u5f88\u7b80\u5355\uff0c\u5206\u522b\u4e09\u4e2a\u6b65\u9aa4\uff0c\u5206\u522b\u4ecb\u7ecd\u5982\u4e0b\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001redis\u5b89\u88c5\u90e8\u7f72<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">redis\u5b89\u88c5\u90e8\u7f72\u6bd4\u8f83\u7b80\u5355\uff0c\u9996\u5148\u4ece<a href=\"https:\/\/redis.io\">https:\/\/redis.io<\/a> \u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684redis\uff0c\u8fd9\u91cc\u4e0b\u8f7d\u7684\u662fredis7.x\u7248\u672c\uff0c\u7136\u540e\u7f16\u8bd1\u5373\u53ef\uff0c\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# tar zxvf redis-7.0.9.tar.gz<br>[root@localhost ~]# cd redis-7.0.9<br>[root@localhost redis-7.0.9]# make<br>[root@localhost redis-7.0.9]# make install<br>[root@localhost redis-7.0.9]# cp redis.conf \/etc #\u62f7\u8d1d\u914d\u7f6e\u6587\u4ef6\u5230\/etc\u76ee\u5f55\u4e0b<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2\u3001\u914d\u7f6eredis\u5e76\u542f\u52a8<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6253\u5f00redis\u914d\u7f6e\u6587\u4ef6\/etc\/redis.conf,\u4fee\u6539\u4e24\u4e2a\u914d\u7f6e\u9879\u7684\u503c\u4e3a\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bind 0.0.0.0<br>daemonize yes<br>protected-mode no<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u542f\u52a8redis\u670d\u52a1\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# \/usr\/local\/bin\/redis-server \/etc\/redis.conf <\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3\u3001tomcat\u5b89\u88c5\u90e8\u7f72<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u90e8\u7f72tomcat\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5b89\u88c5JDK\uff0c\u8fd9\u91cc\u9009\u62e9JDK1.8\u7248\u672c\uff0c\u4eceoracle\u5b98\u7f51\u4e0b\u8f7dlinux-64\u7248\u672c\u7684JDK\uff0c\u4e0b\u8f7d\u65f6\uff0c\u9009\u62e9\u9002\u5408\u81ea\u5df1\u673a\u5668\u8fd0\u884c\u73af\u5883\u7684\u7248\u672c\uff0coracle\u5b98\u7f51\u63d0\u4f9b\u7684JDK\u90fd\u662f\u4e8c\u8fdb\u5236\u7248\u672c\u7684\uff0c\u56e0\u6b64\uff0cJDK\u7684\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u5c06\u4e0b\u8f7d\u4e0b\u6765\u7684\u7a0b\u5e8f\u5305\u89e3\u538b\u5230\u76f8\u5e94\u7684\u76ee\u5f55\u5373\u53ef\u3002\u5b89\u88c5\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# mkdir \/usr\/java<br>[root@localhost ~]# tar -zxvf jdk-8u201-linux-x64.tar.gz -C \/usr\/java\/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u6211\u4eec\u5c06JDK\u5b89\u88c5\u5230\u4e86\/usr\/java\/\u76ee\u5f55\u4e0b\u3002\u63a5\u7740\uff0c\u8981\u8ba9\u7a0b\u5e8f\u80fd\u591f\u8bc6\u522bJDK\u8def\u5f84\uff0c\u8fd8\u9700\u8981\u8bbe\u7f6eJDK\u7684\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u91cc\u6211\u4eec\u5c06JDK\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u5230\/etc\/profile\u6587\u4ef6\u4e2d\u3002\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\u5230\/etc\/profile\u6587\u4ef6\u6700\u540e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export JAVA_HOME=\/usr\/java\/jdk1.8.0_201<br>export PATH=$PATH:$JAVA_HOME\/bin<br>exportCLASSPATH=.:$JAVA_HOME\/lib\/tools.jar:$JAVA_HOME\/lib\/dt.jar:$CLASSPATH<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u8ba9\u8bbe\u7f6e\u751f\u6548\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# source \/etc\/profile<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u5728Shell\u63d0\u793a\u7b26\u4e2d\u6267\u884c\u201cjava -version\u201d\u547d\u4ee4\uff0c\u5982\u679c\u663e\u793a\u5982\u4e0b\u7ed3\u679c\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# java -version<br>java version \"1.8.0_201\"<br>Java(TM) SE Runtime Environment (build 1.8.0_201-b09)<br>Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">JDK\u90e8\u7f72\u6210\u529f\u540e\uff0c\u5c31\u53ef\u4ee5\u90e8\u7f72tomcat\u4e86\uff0ctomcat\u7684\u5b89\u88c5\u5f88\u7b80\u5355\uff0c\u4ece<a href=\"http:\/\/tomcat.apache.org\/\">http:\/\/tomcat.apache.org\/<\/a> \u4e0b\u8f7d\u6700\u65b0\u7684tomcat\uff0c\u7136\u540e\u89e3\u538b\u5373\u53ef\uff0c\u8fd9\u91cc\u4e0b\u8f7dtomcat9\u7248\u672c\uff0c\u5b89\u88c5\u5230\/usr\/loca\/\u76ee\u5f55\u4e0b\uff0c\u6267\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]# tar zxvf apache-tomcat-9.0.72.tar.gz -C \/usr\/local<br>[root@localhost ~]# mv \/usr\/local\/apache-tomcat-9.0.72 \/usr\/local\/tomcat9<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6837\uff0ctomcat\u4e5f\u5b89\u88c5\u5b8c\u6210\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4\u3001tomcat\u4e0eredis\u6574\u5408\u5b9e\u73b0session\u5171\u4eab<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\u5c31\u662f\u914d\u7f6etomcat\u4e86\uff0c\u8981\u914d\u7f6etomcat\u548credis\u6574\u5408\uff0c\u5b9e\u73b0session\u7ba1\u7406\uff0c\u9700\u8981\u51e0\u4e2a\u6b65\u9aa4\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\uff081\uff09\u3001\u90e8\u7f72jar\u5305<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636egithub\u4e0a\u7684\u8bf4\u660e \uff0c\u9700\u8981\u4e0b\u8f7d\u4e24\u4e2ajar\u5305\uff0c\u6839\u636e\u6211\u4eec\u7684\u73af\u5883\uff0c\u5206\u522b\u662fredisson-all-3.20.0.jar\u548credisson-tomcat-9-3.20.0.jar\uff0c\u8fd9\u4e24\u4e2ajar\u5305\u90fd\u53ef\u4ee5\u4ece<a href=\"https:\/\/github.com\/redisson\/redisson\/tree\/master\/redisson-tomcat\">https:\/\/github.com\/redisson\/redisson\/tree\/master\/redisson-tomcat<\/a> \u4e0b\u8f7d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5728\u6700\u65b0\u7684redisson\u7248\u672c\u4e2d,\u8fd8\u9700\u8981\u53e6\u4e00\u4e2a\u4f9d\u8d56jar\u5305fst,\u6211\u8fd9\u91cc\u4e0b\u8f7d\u7684\u662ffst-2.57.jar<\/strong>,\u5982\u679c\u6ca1\u6709\u6b64jar\u5305,tomcat\u542f\u52a8\u4f1a\u51fa\u9519,\u5c06\u4e0b\u8f7d\u4e0b\u6765\u7684jar\u5305\u653e\u5230$TOMCAT_BASE\/lib\u76ee\u5f55\u4e0b\u5373\u53ef\uff0c\u6211\u4eec\u8fd9\u91cc\u7684\u8def\u5f84\u662f\/usr\/local\/tomcat9\/lib\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\uff082\uff09\u3001\u589e\u52a0RedissonSessionManager\u914d\u7f6e<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u6b65\u9aa4\u662f\u5728tomcat\u7684\u914d\u7f6e\u6587\u4ef6$TOMCAT_BASE\/conf\/context.xml\u4e2d\uff0c\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> &lt;Manager className=\"org.redisson.tomcat.RedissonSessionManager\"<br> &nbsp; &nbsp;configPath=\"${catalina.base}\/conf\/redisson.json\" readMode=\"REDIS\" updateMode=\"DEFAULT\"\/&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\uff0c{catalina.base}\/conf\/redisson.json\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{<br> &nbsp;\"singleServerConfig\":{<br> &nbsp; \"idleConnectionTimeout\":10000,<br> &nbsp; \"connectTimeout\":10000,<br> &nbsp; \"timeout\":3000,<br> &nbsp; \"retryAttempts\":3,<br> &nbsp; \"retryInterval\":1500,<br> &nbsp; \"password\":null,<br> &nbsp; \"subscriptionsPerConnection\":5,<br> &nbsp; \"clientName\":null,<br> &nbsp; \"address\": \"redis:\/\/172.16.213.28:6379\",<br> &nbsp; \"subscriptionConnectionMinimumIdleSize\":1,<br> &nbsp; \"subscriptionConnectionPoolSize\":50,<br> &nbsp; \"connectionMinimumIdleSize\":32,<br> &nbsp; \"connectionPoolSize\":64,<br> &nbsp; \"database\":0,<br> &nbsp; \"dnsMonitoringInterval\":5000<br>  },<br>\u200b<br> &nbsp;\"threads\":0,<br> &nbsp;\"nettyThreads\":0,<br> &nbsp;\"codec\":{<br> &nbsp; \"class\":\"org.redisson.codec.FstCodec\"<br>  },<br> &nbsp;\"transportMode\":\"NIO\"<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9700\u8981\u6ce8\u610f\u8fd9\u91cc\u9762\u7684&#8221;address&#8221;\u4e00\u9879\u7684\u503c\uff0c\u5982\u679ctomcat\u548credis\u5b89\u88c5\u5728\u4e00\u8d77\uff0c\u53ef\u4ee5\u5199\u6210127.0.0.1:6379\uff0c\u5982\u679credis\u5728\u72ec\u7acb\u7684\u4e00\u53f0\u673a\u5668\u4e0a\uff0c\u5c31\u5199redis\u6240\u5728\u673a\u5668\u7684IP\u5730\u5740\u3002\u8fd9\u91ccredis\u6240\u5728\u7684IP\u4e3a172.16.213.28\uff0c\u6240\u4ee5\u4e0a\u9762\u5c31\u5199\u8fd9\u4e2a\u5730\u5740\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5230\u6b64\u4e3a\u6b62\uff0ctomcat\u4e0eredis\u7684\u4e92\u8054\u914d\u7f6e\u5b8c\u6210\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5\u3001\u6d4b\u8bd5\u83b7\u53d6session<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728tomcat\u7684$TOMCAT_BASE\/webapps\/ROOT\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2atestsession.jsp\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"utf-8\"%&gt;<br>&lt;%<br> &nbsp; &nbsp; &nbsp; &nbsp;String path = request.getContextPath();<br> &nbsp; &nbsp; &nbsp; &nbsp;String basePath = request.getScheme() + \":\/\/\"<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ request.getServerName() + \":\" + request.getServerPort()<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ path + \"\/\";<br>%&gt;<br>&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"&gt;<br>&lt;html&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;head&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;title&gt;tomcat1&lt;\/title&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;\/head&gt;<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;body&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;center&gt;&lt;h1&gt;tomcat1&lt;\/h1&gt;&lt;\/center&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;center&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h3&gt;sessionId:&lt;\/h3&gt;&lt;%=session.getId()%&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h3&gt;session\u521b\u5efa\u65f6\u95f4\uff1a&lt;\/h3&gt;&lt;%=session.getCreationTime()%&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;center&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;\/body&gt;<br>&lt;\/html&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u7740\uff0c\u542f\u52a8tomcat\u670d\u52a1\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[root@localhost ~]#\/usr\/local\/tomcat9\/bin\/startup.sh<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u542f\u52a8tomcat\u540e\uff0c\u5728\u6d4f\u89c8\u5668\u8bbf\u95ee\uff1a<a href=\"http:\/\/172.16.213.28:8080\/testsession.jsp\">http:\/\/172.16.213.28:8080\/testsession.jsp<\/a>, \u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-7-1024x194.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"194\" data-original=\"http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-7-1024x194.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-65\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\uff0c\u767b\u5f55redis\u5ba2\u6237\u7aef\uff0c\u67e5\u770bkey\u4fe1\u606f\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@localhost ~]#redis-cli <br>127.0.0.1:6379&gt; keys *<br>1) \"redisson:tomcat_session:3C9CCFDD65022303DDCEDB1180A1703A\"<br>127.0.0.1:6379&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u770b\u5230\uff0credis\u91cc\u9762\u5df2\u7ecf\u751f\u6210\u4e86session\u4fe1\u606f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6\u3001\u90e8\u7f72\u7b2c\u4e8c\u4e2atomcat\u5b9e\u4f8b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u5df2\u7ecf\u90e8\u7f72\u597d\u4e86\u7b2c\u4e00\u53f0tomcat\u5b9e\u4f8btomcat1\uff0c\u63a5\u7740\u5728172.16.213.29\u4e0a\u90e8\u7f72\u53e6\u4e00\u4e2atomcat\u5b9e\u4f8btomcat2\uff0c\u6700\u7b80\u5355\u7684\u90e8\u7f72\u65b9\u6cd5\u662f\u76f4\u63a5\u62f7\u8d1d\u7b2c\u4e00\u4e2atomcat1\u5b9e\u4f8b\u5230172.16.213.29\u4e0a\u5bf9\u5e94\u7684\u4f4d\u7f6e\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4e86\u4e24\u4e2atomcat\u5b9e\u4f8b\u8fdb\u884c\u533a\u5206\uff0c\u8fd9\u91cc\u9700\u8981\u4fee\u6539testsession.jsp\u6587\u4ef6\u4e2d\u7684\u4e00\u4e9b\u6807\u8bc6\u4fe1\u606f\uff0c\u4fee\u6539\u540e\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"utf-8\"%&gt;<br>&lt;%<br> &nbsp; &nbsp; &nbsp; &nbsp;String path = request.getContextPath();<br> &nbsp; &nbsp; &nbsp; &nbsp;String basePath = request.getScheme() + \":\/\/\"<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ request.getServerName() + \":\" + request.getServerPort()<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ path + \"\/\";<br>%&gt;<br>\u200b<br>&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\"&gt;<br>&lt;html&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;head&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;title&gt;tomcat2&lt;\/title&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;\/head&gt;<br>\u200b<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;body&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;center&gt;&lt;h1&gt;tomcat2&lt;\/h1&gt;&lt;\/center&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;center&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h3&gt;sessionId:&lt;\/h3&gt;&lt;%=session.getId()%&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h3&gt;session\u521b\u5efa\u65f6\u95f4\uff1a&lt;\/h3&gt;&lt;%=session.getCreationTime()%&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;center&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;\/body&gt;<br>\u200b<br>&lt;\/html&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u4e3b\u8981\u662f\u5c06\u6587\u4ef6\u4e2d\u7684tomcat1\u4fee\u6539\u4e3a\u4e86tomcat2\uff0c\u6700\u540e\uff0c\u8fd8\u9700\u8981\u5728172.16.213.29\u4e0a\u5b89\u88c5\u548c\u914d\u7f6eJDK\uff0c\u8fd9\u4e2a\u4e0a\u9762\u5df2\u7ecf\u505a\u4e86\u4ecb\u7ecd\uff0c\u8fd9\u91cc\u4e0d\u518d\u8bf4\u660e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u6709\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u542f\u52a8tomcat\u670d\u52a1\uff0c\u7136\u540e\u8bbf\u95ee<a href=\"http:\/\/172.16.213.29:8080\/testsession.jsp\">http:\/\/172.16.213.29:8080\/testsession.jsp<\/a>, \u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-6-1024x235.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"235\" data-original=\"http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-6-1024x235.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-64\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u770b\u5230\uff0c\u901a\u8fc7172.16.213.28\u548c172.16.213.29\u8bbf\u95eetestsession.jsp\u9875\u9762\u5f97\u5230\u7684session\u4fe1\u606f\u662f\u4e0d\u4e00\u6837\u7684\u3002\u8fd9\u662f\u6b63\u5e38\u7684\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7\u3001\u90e8\u7f72nginx\u8d1f\u8f7d\u5747\u8861<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u4e0a\u9762\u7684\u5b9a\u4e49\uff0cnginx\u662f\u5b89\u88c5\u5728172.16.213.30\u670d\u52a1\u5668\u4e0a\uff0c\u4ecenginx\u5b98\u7f51<a href=\"http:\/\/nginx.org\/\">http:\/\/nginx.org\/<\/a> \u4e0b\u8f7d\u6700\u65b0\u7684nginx\u7248\u672c\uff0c\u8fd9\u91cc\u662fnginx-1.23\u7248\u672c\uff0c\u7136\u540e\u8fdb\u884c\u7f16\u8bd1\u5b89\u88c5\uff0c\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@centos ~]# yum -y install zlib pcre pcre-devel openssl openssl-devel<br>[root@centos ~]# useradd -s \/sbin\/nologin www<br>[root@centos ~]#tar zxvf nginx-1.23.3.tar.gz<br>[root@centos ~]#cd nginx-1.23.3<br>[root@centos nginx-1.23.3]# .\/configure \\<br>--user=www \\<br>--group=www \\<br>--prefix=\/usr\/local\/nginx \\<br>--sbin-path=\/usr\/local\/nginx\/sbin\/nginx \\<br>--conf-path=\/usr\/local\/nginx\/conf\/nginx.conf \\<br>--error-log-path=\/usr\/local\/nginx\/logs\/error.log \\<br>--http-log-path=\/usr\/local\/nginx\/logs\/access.log \\<br>--pid-path=\/var\/run\/nginx.pid \\<br>--lock-path=\/var\/lock\/subsys\/nginx \\<br>--with-http_stub_status_module \\<br>--with-http_ssl_module \\<br>--with-http_gzip_static_module \\<br>--with-pcre<br>[root@centos nginx-1.23.3]# make<br>[root@centos nginx-1.23.3]# make install<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6837\uff0cnginx\u5c31\u5b89\u88c5\u5b8c\u6210\u4e86\u3002\u63a5\u4e0b\u6765\uff0c\u5c31\u662f\u914d\u7f6enginx\u4e86\uff0c\u6253\u5f00nginx\u914d\u7f6e\u6587\u4ef6nginx.conf\uff0c\u91cd\u70b9\u4fee\u6539\u5982\u4e0b\u90e8\u5206\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">user &nbsp;www;<br>worker_processes &nbsp;8;<br>events {<br> &nbsp; &nbsp;worker_connections &nbsp;65536;<br>}<br>http {<br> &nbsp; &nbsp;include &nbsp; &nbsp; &nbsp; mime.types;<br> &nbsp; &nbsp;default_type &nbsp;application\/octet-stream;<br> &nbsp; &nbsp;sendfile &nbsp; &nbsp; &nbsp; &nbsp;on;<br> &nbsp; &nbsp;keepalive_timeout &nbsp;65;<br> &nbsp; upstream tomcat {<br> &nbsp; &nbsp; server 172.16.213.28:8080 weight=1;<br> &nbsp; &nbsp; server 172.16.213.29:8080 weight=1;<br> &nbsp;  }<br>\u200b<br> &nbsp; &nbsp;server {<br> &nbsp; &nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 80;<br> &nbsp; &nbsp; &nbsp; &nbsp;server_name &nbsp;localhost;<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;location \/ {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_pass http:\/\/tomcat;<br> &nbsp; &nbsp; &nbsp;  }<br>\u200b<br> &nbsp; &nbsp; &nbsp; &nbsp;error_page &nbsp; 500 502 503 504 &nbsp;\/50x.html;<br> &nbsp; &nbsp; &nbsp; &nbsp;location = \/50x.html {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; html;<br> &nbsp; &nbsp; &nbsp;  }<br>\u200b<br> &nbsp;  }<br>}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u542f\u52a8nginx\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@centos nginx-1.23.3]# \/usr\/local\/nginx\/sbin\/nginx <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u6d4b\u8bd5nginx+tomcat+redis\u7684session\u5171\u4eab\u529f\u80fd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">nginx\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7<a href=\"http:\/\/172.16.213.30\/testsession.jsp\">http:\/\/172.16.213.30\/testsession.jsp<\/a> \u8bbf\u95ee\u4e24\u4e2atomcat\u5b9e\u4f8b\u4e86\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-3-1024x264.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"264\" data-original=\"http:\/\/43.136.56.131\/wp-content\/uploads\/2026\/04\/image-3-1024x264.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-61\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u770b\u5230\uff0c\u5982\u679c\u4e0d\u505c\u5237\u65b0\u8fd9\u4e2a\u9875\u9762\u7684\u8bdd\uff0c\u4f1a\u5728\u4e24\u4e2atomcat\u5b9e\u4f8b\u4e4b\u95f4\u6765\u56de\u8f6e\u8be2\u5207\u6362\uff0c\u4f46session\u503c\u5e76\u4e0d\u53d1\u751f\u53d8\u5316\uff0c\u8fd9\u8bf4\u660e\u4e24\u4e2atomcat\u5b9e\u4f8b\u90fd\u5171\u4eab\u4e86redis\u91cc\u9762\u5b58\u50a8\u7684session\u4fe1\u606f\uff0c\u4e5f\u5c31\u662f\u5b9e\u73b0\u4e86nginx+tomcat+redis\u7684session\u5171\u4eab\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5206\u5e03\u5f0fSession\u5171\u4eab\u65b9\u6848\u7684\u7531\u6765 \u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u65f6\u5019\uff0c\u670d\u52a1\u5668\u628a\u5ba2\u6237\u7aef\u4fe1\u606f\u4ee5\u67d0\u79cd\u5f62\u5f0f\u8bb0\u5f55\u5728\u670d\u52a1\u5668 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":33,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-learn"],"_links":{"self":[{"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":1,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/posts\/60\/revisions\/66"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/media\/33"}],"wp:attachment":[{"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mm1.asia\/index.php\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}