{"id":39,"date":"2021-07-29T00:08:50","date_gmt":"2021-07-28T16:08:50","guid":{"rendered":"http:\/\/blog.nonot.cn\/?p=39"},"modified":"2024-07-08T13:11:59","modified_gmt":"2024-07-08T05:11:59","slug":"%e4%b8%80%e4%b8%aatomcat%e4%b8%8b%e9%83%a8%e7%bd%b2%e4%b8%8d%e5%90%8c%e7%ab%af%e5%8f%a3%e5%a4%9a%e4%b8%aa%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2021\/07\/29\/%e4%b8%80%e4%b8%aatomcat%e4%b8%8b%e9%83%a8%e7%bd%b2%e4%b8%8d%e5%90%8c%e7%ab%af%e5%8f%a3%e5%a4%9a%e4%b8%aa%e5%ba%94%e7%94%a8\/","title":{"rendered":"\u4e00\u4e2atomcat\u4e0b\u90e8\u7f72\u4e0d\u540c\u7aef\u53e3\u591a\u4e2a\u5e94\u7528"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u914d\u7f6etmcat\u7684server.xml\u6765\u5b9e\u73b0\u591a\u7aef\u53e3\u591a\u5e94\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version='1.0' encoding='utf-8'?>\n\n&lt;Server port=\"8005\" shutdown=\"SHUTDOWN\">\n&lt;!-- Security listener. Documentation at \/docs\/config\/listeners.html\n&lt;Listener className=\"org.apache.catalina.security.SecurityListener\" \/>\n-->\n&lt;!--APR library loader. Documentation at \/docs\/apr.html -->\n&lt;Listener className=\"org.apache.catalina.core.AprLifecycleListener\" SSLEngine=\"on\" \/>\n&lt;!--Initialize Jasper prior to webapps are loaded. Documentation at \/docs\/jasper-howto.html -->\n&lt;Listener className=\"org.apache.catalina.core.JasperListener\" \/>\n&lt;!-- Prevent memory leaks due to use of particular java\/javax APIs-->\n&lt;Listener className=\"org.apache.catalina.core.JreMemoryLeakPreventionListener\" \/>\n&lt;Listener className=\"org.apache.catalina.mbeans.GlobalResourcesLifecycleListener\" \/>\n&lt;Listener className=\"org.apache.catalina.core.ThreadLocalLeakPreventionListener\" \/>\n\n&lt;GlobalNamingResources>\n&lt;Resource name=\"UserDatabase\" auth=\"Container\"\ntype=\"org.apache.catalina.UserDatabase\"\ndescription=\"User database that can be updated and saved\"\nfactory=\"org.apache.catalina.users.MemoryUserDatabaseFactory\"\npathname=\"conf\/tomcat-users.xml\" \/>\n&lt;\/GlobalNamingResources>\n\n\n&lt;Service name=\"Catalina\">\n\n&lt;Connector port=\"8080\" protocol=\"org.apache.coyote.http11.Http11AprProtocol\" URIEncoding=\"UTF-8\" \nenableLookups=\"false\" \nacceptCount=\"500\" \nconnectionTimeout=\"5000\" \ndisableUploadTimeout=\"true\" maxThreads=\"1500\" maxSpareThreads=\"50\" minSpareThreads=\"25\"\nredirectPort=\"8443\" \/>\n\n&lt;Connector port=\"8009\" protocol=\"AJP\/1.3\" redirectPort=\"8443\" \/>\n&lt;Engine name=\"Catalina\" defaultHost=\"localhost\">\n&lt;Realm className=\"org.apache.catalina.realm.LockOutRealm\">\n&lt;Realm className=\"org.apache.catalina.realm.UserDatabaseRealm\"\nresourceName=\"UserDatabase\"\/>\n&lt;\/Realm>\n\n&lt;Host name=\"localhost\" appBase=\"webapps\"\nunpackWARs=\"true\" autoDeploy=\"true\">\n&lt;Context docBase=\"\/data\/java\/appstore-api\" path=\"\/\" reloadable=\"false\" \/>\n&lt;\/Host>\n&lt;\/Engine>\n&lt;\/Service>\n\n&lt;Service name=\"web\">\n&lt;Connector port=\"8088\" protocol=\"HTTP\/1.1\" maxThreads=\"700\" acceptCount=\"100\" connectionTimeout=\"2000\" redirectPort=\"8445\" URIEncoding=\"UTF-8\"\/>\n\n&lt;Engine name=\"web\" defaultHost=\"localhost\">\n&lt;Host name=\"localhost\" appBase=\"webapp1\">\n&lt;Context docBase=\"\/data\/java\/appstore-web\" path=\"\" reloadable=\"true\" \/>\n&lt;\/Host>\n&lt;\/Engine>\n&lt;\/Service>\n\n&lt;Service name=\"web2\">\n&lt;Connector port=\"8089\" protocol=\"HTTP\/1.1\" maxThreads=\"700\" acceptCount=\"100\" connectionTimeout=\"2000\" redirectPort=\"8445\" URIEncoding=\"UTF-8\"\/>\n&lt;Engine name=\"web2\" defaultHost=\"localhost\">\n&lt;Host name=\"localhost\" appBase=\"webapp2\">\n&lt;Context docBase=\"\/data\/java\/appstore-web2\" path=\"\" reloadable=\"true\" \/>\n&lt;\/Host>\n&lt;\/Engine>\n&lt;\/Service>\n&lt;\/Server><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u6309\u7167\u4e0a\u9762\u7684\u914d\u7f6e\uff0c\u542f\u52a8tomcat\uff0c\u53ef\u4ee5\u53d1\u73b0\uff1a<br>1\uff09\u542f\u52a8tomcat\u540e\uff0c\u5728tomcat\u914d\u7f6e\u76ee\u5f55\uff1a\/usr\/local\/tomcat\/conf\u4e0b\uff0c\u9664\u4e86\u9ed8\u8ba4\u7684Catalina\u6587\u4ef6\u5939\u5916\uff0c\u8fd8\u4f1a\u751f\u6210web1\u548cweb2\u4e24\u4e2a\u6587\u4ef6\u5939\u3002\u539f\u56e0\u662fEngine\u7ec4\u4ef6\u4e2d\uff0c\u6307\u5b9a\u4e86\u6240\u7528\u7684web1\u548cweb2\u3002\u5f53\u7136\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u4e0d\u540cservice\u7ec4\u4ef6\u7684Engine name\u90fd\u6307\u5b9a\u6210Catalina\u3002<br>2\uff09\u542f\u52a8tomcat\u540e\uff0c\u5728tomcat\u76ee\u5f55\uff1a\/usr\/local\/tomcat\u4e0b\uff0c\u9664\u4e86\u9ed8\u8ba4\u7684webapps\u6587\u4ef6\u5939\u5916\uff0c\u8fd8\u4f1a\u751f\u6210webapp1\u548cwebapp2\u4e24\u4e2a\u76ee\u5f55\u3002\u539f\u56e0\u662fHost\u7ec4\u4ef6\u4e2d\uff0c\u6307\u5b9a\u4e86appBase\u4f1fwebapp1\u548cwebapp2.\u5f53\u7136\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u4e0d\u540cservice\u7ec4\u4ef6\u7684Host appBase\u6307\u5b9a\u6210\u9ed8\u8ba4\u7684webapps\u3002<br>3\uff09&lt;Context docBase=&#8221;\/data\/java\/appstore-web&#8221; path=&#8221;&#8221; reloadable=&#8221;true&#8221; \/&gt; \u8fd9\u4e2a\u7528\u4e8e\u914d\u7f6e\u6839\u8def\u5f84\u9879\u76ee\uff0c\u4e5f\u5c31\u662f\/data\/java\/appstore-web\u5305\u8bbf\u95ee\u65f6\u662f\u901a\u8fc7ip:port\u6765\u8bbf\u95ee\uff0c\u800c\u4e0d\u662f\u4f20\u7edf\u7684ip:port\/app<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u914d\u7f6e\u8bf4\u660e\uff1a<br>1\uff09<strong>appBase\u662f\u865a\u62df\u4e3b\u673a\u5b58\u653ewebapp\u7684\u76ee\u5f55<\/strong>\uff0c\u5b83\u53ef\u4ee5\u662f\u76f8\u5bf9\u8def\u5f84\uff0c\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\u3002\u5982\u679c\u662f\u76f8\u5bf9\u8def\u5f84\uff0c\u5219\u76f8\u5bf9\u4e8e$CATALINA_HOME\uff0c\u4e25\u683c\u5e76\u51c6\u786e\u5730\u8bf4\u662fCATALINA_BASE\u3002<br>2\uff09<strong>path\u662fURI\u7684\u5339\u914d\u8def\u5f84\uff0c\u76f8\u5f53\u4e8enginx\u7684location\u540e\u7684\u8def\u5f84<\/strong>\u3002tomcat\u8981\u6c42\u6bcf\u4e2a\u865a\u62df\u4e3b\u673a\u5fc5\u987b\u914d\u7f6e\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u7684path\uff0c\u8be5\u6761context\u4f5c\u4e3aURI\u65e0\u6cd5\u88ab\u660e\u786e\u5339\u914d\u65f6\u7684\u9ed8\u8ba4context\uff0c\u5b83\u76f8\u5f53\u4e8enginx\u4e2dlocation \/ {}\u7684\u4f5c\u7528\u3002<br>3\uff09<strong>docBase\u5219\u662f\u6bcf\u4e2awebapp\u7684\u5b58\u653e\u76ee\u5f55\uff0c\u53ef\u4ee5\u914d\u7f6e\u6587\u4ef6\u5939\u6216\u8005war\u5305\u8def\u5f84<\/strong><br>a. \u5982\u679c\u5982\u679c\u914d\u7f6e\u7684\u662f\u6587\u4ef6\u5939\uff0c\u5b83\u53ef\u4ee5\u662f\u76f8\u5bf9\u8def\u5f84\uff0c\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\uff0c\u63d0\u4f9b\u76f8\u5bf9\u8def\u5f84\u65f6\u5b83\u76f8\u5bf9\u4e8eappBase\u3002\u8be5\u76ee\u5f55\u4e00\u822c\u5728appBase\u7684\u76ee\u5f55\u4e0b\uff0c\u4f46\u5e76\u4e0d\u89c4\u5b9a\u4e00\u5b9a\u8981\u653e\u5728appBase\u4e0b\uff0c\u6bd4\u5982<br>&lt;Context docBase=&#8221;\/data\/java\/appstore-web&#8221; path=&#8221;&#8221; reloadable=&#8221;true&#8221; \/&gt;<br>\u5c31\u4f1a\u5c06\u8fd9\u4e2a\u6587\u4ef6\u5939\u5f53\u6210ROOT web\u6765\u8bbf\u95ee\uff0c\u8bbf\u95ee\u5730\u5740\u662fip:port \u800c\u4e0d\u662fip:port\/appstore-web<br>\uff08\u5bf9\u4e8eweb\u670d\u52a1\u6765\u8bf4\uff0c\u5b83\u76f8\u5f53\u4e8enginx\u7684root\u6307\u4ee4\uff0c\u4f46\u5bf9\u4e8ewebapp\u6765\u8bf4\uff0c\u4e00\u4e2acontext\u5c31\u76f8\u5f53\u4e8e\u4e00\u4e2awebapp\uff0c\u800cdocBase\u6b63\u662fwebapp\u7684\u8def\u5f84\u3002\uff09<br>b. \u5982\u679c\u914d\u7f6e\u7684\u662fwar\u6587\u4ef6\uff0c\u6bd4\u5982<br>&lt;Context docBase=&#8221;\/data\/java\/appstore-web.war&#8221; path=&#8221;&#8221; reloadable=&#8221;true&#8221; \/&gt;<br>\u5c31\u4f1a\u5c06\u8fd9\u4e2ajar\u6587\u4ef6\u89e3\u538b\u5230webapp1\u7684ROOT\u6587\u4ef6\u5939\u4e2d\uff0c\u5f53\u6210ROOT web\u6765\u8bbf\u95ee\uff0c\u8bbf\u95ee\u5730\u5740\u662fip:port \u800c\u4e0d\u662fip:port\/appstore-web<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u53e6\u5916\u5982\u679capp\u9700\u8981\u5c06\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u5f15\u5165tomcat \u53ef\u4ee5\u5728tomcat catalina.properties\u4e2d\u589e\u52a0\u659c\u7c97\u4f53\u90e8\u5206<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">common.loader=${catalina.base}\/lib,${catalina.base}\/lib\/*.jar,${catalina.home}\/lib,${catalina.home}\/lib\/*.jar,<em><strong>${catalina.home}\/appconfig<\/strong><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u914d\u7f6etmcat\u7684server.xml\u6765\u5b9e\u73b0\u591a\u7aef\u53e3\u591a\u5e94\u7528\uff1a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-tomcat"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":1,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":1282,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions\/1282"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}