Tomcat8瀹夎锛?瀹夊叏閰嶇疆涓庢€ц兘浼樺寲
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tomcat8瀹夎锛?瀹夊叏閰嶇疆涓庢€ц兘浼樺寲相关的知识,希望对你有一定的参考价值。
鏍囩锛?/p>
鍘熸枃锛歨ttp://blog.csdn.net/our_sky/article/details/51362676
涓€銆乀omcat 瀹夎
- 瀹樼綉锛?a href="https://tomcat.apache.org/" target="_blank">http://tomcat.apache.org/
- Tomcat8瀹樼綉涓嬭浇鍦板潃锛?a href="https://tomcat.apache.org/download-80.cgi" target="_blank">http://tomcat.apache.org/download-80.cgi
- 涓轰簡渚夸簬鏂囦欢绠$悊锛屼釜浜轰範鎯? 鍦?opt鐩綍涓嬪垱寤?涓€涓猧nstall鐩綍鐢ㄤ簬瀛樻斁 杞欢瀹夎鍖咃紝鍦?usr 鐩綍涓嬪垱寤簂ocal鏂囦欢澶圭敤鎴峰瓨鏀捐В鍘嬫枃浠?nbsp;
- 涓嬭浇瀹夎鍖咃細 wget http://apache.fayea.com/tomcat/tomcat-8/v8.0.32/bin/apache-tomcat-8.0.32.tar.gz
- 瑙e帇鍘嬬缉鍖咃細 tar -zxvf apache-tomcat-8.0.32.tar.gz
- 绉诲姩瑙e帇鏂囦欢鍒?mv apache-tomcat-8.0.32/ /usr/local/
- 涓烘柟渚胯捣瑙侊紝鍙互浣跨敤 mv /usr/local/apache-tomcat-8.0.32/ /usr/local/tomcat8/ 淇敼鐩綍鍚嶇О
sudo /etc/rc.d/init.d/iptables save
浜屻€乀omcat 瀹夊叏閰嶇疆涓庝紭鍖?/h1>
2.1浼樺寲server.xml
2.1.1 闅愯棌鐗堟湰淇℃伅
- 闅愯棌HTTP 澶撮儴鐨勭増鏈俊鎭?銆?nbsp;
缂栬緫server.xml: vi /usr/local/tomcat8/conf/server.xml
- <span style="font-family:Consolas, Liberation Mono, Menlo, Courier, monospace;"> </span><span style="font-family:Microsoft YaHei;"> <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" server="APP Srv1.0"/></span>
- 闅愯棌404椤甸潰鍑虹幇鐨勭増鏈彿
鎴戜滑鍙互閫氳繃 jar xf 鍛戒护瑙e帇杩欎釜 jar 鍖呬細寰楀埌涓や釜鐩綍 META-INF 鍜?org ,閫氳繃淇敼 org/apache/catalina/util/ServerInfo.properties 鏂囦欢涓? 鐨?serverinfo 瀛楁鏉ュ疄鐜版潵鏇存敼鎴戜滑tomcat鐨勭増鏈俊鎭€?/p>
鏂囦欢淇℃伅濡備笅锛?/p>
[[email protected] ~]
# cat /usr/local/tomcat8/lib/org/apache/catalina/util/ServerInfo.properties |grep -v 鈥榐$|#鈥?/code>
server.info=Apache Tomcat
/8
.0.23
server.number=8.0.23.0
server.built=Mar 18 2016 20:31:49 UTC
杩樻湁鍙﹀涓€绉嶆柟娉曟潵瀹炵幇闅愯棌鎴栦吉瑁匱omcat鐨勭増鏈俊鎭紝鍏舵湰璐ㄥ拰涓婇潰涓€鏍凤紝鎿嶄綔濡備笅锛?/code>
[[email protected] ~]
# cd /usr/local/tomcat8/lib
[[email protected] lib]
# mkdir -p org/apache/catalina/util
[[email protected] lib]
# cd org/apache/catalina/util
[[email protected] util]
# vim ServerInfo.properties
server.info=nolinux
# 濡傛灉鎯充慨鏀规垚鍏跺畠鐗堟湰鍙凤紝鎶婅繖涓湴鏂圭殑鍊兼敼鎴愬叾瀹冨€煎氨琛屼簡
淇敼鏁堟灉濡備笅锛?/p>
2.1.2绂佺敤Tomcat绠$悊鐣岄潰
鐢熶骇鐜涓€鑸笉閫傜敤Tomcat榛樿鐨勭鐞嗙晫闈紝杩欎簺椤甸潰瀛樻斁鍦═omcat 鐨剋ebapps瀹夎鐩綍涓嬶紝
鎶婅鐩綍涓嬬殑鎵€鏈夋枃浠跺垹闄ゅ嵆鍙細rm -rf /usr/local/tomcat8/webapps/*
鍙﹀鍒犻櫎鐩稿叧鐨勯厤缃枃浠?nbsp;host-manager.xml 鍜?manager.xml锛屽湪Tomcat 瀹夎鐩綍 conf/Catalina/localhost鐩綍涓嬨€?/p>
娉ㄩ噴鎴栧垹闄omcat_user.xml 涓殑鎵€鏈夌敤鎴锋潈闄愩€?/p>
2.1.3 搴旂敤绋嬪簭瀹夊叏
tomcat榛樿 寮€鍚簡瀵箇ar鐑儴缃层€備负浜嗛槻姝㈣妞嶅叆鏈ㄩ┈鎭舵剰鏀诲嚮锛屾垜浠鍏抽棴war鍖呰嚜鍔ㄩ儴缃层€?/p>
鍏抽棴鑷姩鍔犺浇鏈€鏂颁唬鐮侊紙璁剧疆reloadable锛?/p>
淇敼瀹炰緥锛?nbsp;
- <Host name="localhost" appBase="webapps"
- unpackWARs="false" autoDeploy="false"
- reloadable="false">
2.1.4 鏇存敼鍏抽棴Tomcat鐨勬寚浠?/h3>
server.xml涓畾涔変簡鍙互鐩存帴鍏抽棴 Tomcat 瀹炰緥鐨勭鐞嗙鍙c€傛垜浠€氳繃 telnet 杩炴帴涓婅绔彛涔嬪悗锛岃緭鍏?SHUTDOWN 锛堟涓洪粯璁ゅ叧闂寚 浠わ級鍗冲彲鍏抽棴 Tomcat 瀹炰緥锛堟敞鎰忥紝姝ゆ椂铏界劧瀹炰緥鍏抽棴浜嗭紝浣嗘槸杩涚▼杩樻槸瀛樺湪鐨勶級銆傜敱浜庨粯璁ゅ叧闂?Tomcat 鐨勭鍙e拰鎸囦护閮藉緢绠€鍗曘€傞粯璁ょ鍙d负 8005锛屾寚浠や负SHUTDOWN 銆傚洜姝ゆ垜浠渶瑕佸皢鍏抽棴鎸囦护淇敼澶嶆潅涓€鐐广€?/p>
褰撶劧锛屽湪鏂扮増鐨?Tomcat 涓绔彛浠呯洃鍚湪127.0.0.1涓婏紝鍥犳澶у涔熶笉蹇呮媴蹇冦€傞櫎闈為粦瀹㈢櫥闄嗗埌tomcat鏈満鍘绘墽琛屽叧闂搷浣溿€?/p>
淇敼瀹炰緥锛?/p>
<Server port="8005" shutdown="9SDKJ29jksjf23sjf0LSDF92JKS9DKkjsd">
鎴栬€呯鐢?005绔彛
<Server port="-1" shutdown="SHUTDOWN">
2.1.5 杩炴帴姹犻厤缃?/h3>
浣跨敤绾跨▼姹狅紝鐢ㄨ緝灏戠殑绾跨▼澶勭悊杈冨鐨勮闂紝鍙互鎻愰珮tomcat澶勭悊璇锋眰鐨勮兘鍔涖€?/p>
缂栬緫閰嶇疆鏂囦欢 server.xml : vi /usr/local/tomcat8/conf/server.xml
2.1.5.1 鎵撳紑琚敞閲婄殑榛樿杩炴帴姹犻厤缃?/h4>
榛樿閰嶇疆锛?nbsp;
- <!--
- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
- maxThreads="150" minSpareThreads="4"/>
- -->
- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
- maxThreads="150" minSpareThreads="100"
- prestartminSpareThreads="true" maxQueueSize="100"/>
- name: 绾跨▼鍚嶇О
- namePrefix: 绾跨▼鍓嶇紑
- maxThreads : 鏈€澶у苟鍙戣繛鎺ユ暟锛屼笉閰嶇疆鏃堕粯璁?00锛屼竴鑸缓璁缃?00~ 800 锛岃鏍规嵁鑷繁鐨勭‖浠惰鏂芥潯浠跺拰瀹為檯涓氬姟闇€姹傝€屽畾銆?/li>
- minSpareThreads锛歍omcat鍚姩鍒濆鍖栫殑绾跨▼鏁帮紝榛樿鍊?5
- prestartminSpareThreads锛氬湪tomcat鍒濆鍖栫殑鏃跺€欏氨鍒濆鍖杕inSpareThreads鐨勫€硷紝 涓嶈缃畉rue鏃秏inSpareThreads
- maxQueueSize: 鏈€澶х殑绛夊緟闃熷垪鏁帮紝瓒呰繃鍒欐嫆缁濊姹?/li>
2.1.5.2 淇敼閾炬帴閰嶇疆
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
- <Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
- connectionTimeout="20000"
- redirectPort="8443"
- executor="tomcatThreadPool"
- enableLookups="false"
- acceptCount="100"
- maxPostSize="10485760"
- compression="on"
- disableUploadTimeout="true"
- compressionMinSize="2048"
- noCompressionUserAgents="gozilla, traviata"
- acceptorThreadCount="2"
- compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript"
- URIEncoding="utf-8"/>
- port锛氳繛鎺ョ鍙c€?
- protocol锛氳繛鎺ュ櫒浣跨敤鐨勪紶杈撴柟寮忋€? Tomcat 8 璁剧疆 nio2 鏇村ソ锛歰rg.apache.coyote.http11.Http11Nio2Protocol
- protocol锛?nbsp;Tomcat 6銆? 璁剧疆 nio 鏇村ソ锛歰rg.apache.coyote.http11.Http11NioProtocol
- executor锛?杩炴帴鍣ㄤ娇鐢ㄧ殑绾跨▼姹犲悕绉?/li>
- enableLookups锛氱鐢―NS 鏌ヨ
- acceptCount锛氭寚瀹氬綋鎵€鏈夊彲浠ヤ娇鐢ㄧ殑澶勭悊璇锋眰鐨勭嚎绋嬫暟閮借浣跨敤鏃讹紝鍙互鏀惧埌澶勭悊闃熷垪涓殑璇锋眰鏁帮紝瓒呰繃杩欎釜鏁扮殑璇锋眰灏嗕笉浜堝鐞嗭紝榛樿璁剧疆 100 銆?/li>
- maxPostSize锛氶檺鍒?浠ORM URL 鍙傛暟鏂瑰紡鐨凱OST璇锋眰鐨勫唴瀹瑰ぇ灏忥紝鍗曚綅瀛楄妭锛岄粯璁ゆ槸 2097152(2鍏?锛?0485760 涓?10M銆傚鏋滆绂佺敤闄愬埗锛屽垯鍙互璁剧疆涓?-1銆?/li>
- acceptorThreadCount锛?nbsp;鐢ㄤ簬鎺ユ敹杩炴帴鐨勭嚎绋嬬殑鏁伴噺锛岄粯璁ゅ€兼槸1銆備竴鑸繖涓寚闇€瑕佹敼鍔ㄧ殑鏃跺€欐槸鍥犱负璇ユ湇鍔″櫒鏄竴涓鏍窩PU锛屽鏋滄槸澶氭牳 CPU 涓€鑸厤缃负 2銆?/li>
- compression锛氫紶杈撴椂鏄帇缂┿€?/li>
- compressionMinSize锛氬帇缂╃殑澶у皬
- noCompressionUserAgents锛氫笉鍚敤鍘嬬缉鐨勬祻瑙堝櫒
2.1.6 绠$悊AJP绔彛
- <span style="font-family:Microsoft YaHei;"> <!--<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />--></span>
2.3 搴旂敤绋嬪簭閮ㄧ讲
1
2
3
4
5
6
|
[[email protected] ~] # groupadd tomcat [[email protected] ~] # useradd -g tomcat tomcat [[email protected] ~] # passwd tomcat [[email protected] ~] # chown tomcat.tomcat -R /usr/local/tomcat [[email protected] ~] # su - tomcat /usr/local/tomcat/bin/startup.sh [[email protected] ~] # echo 鈥榮u - tomcat -c "tomcat /usr/local/tomcat/bin/startup.sh"鈥?nbsp;>> /etc/rc.local #寮€鏈哄惎鍔?/code> |
以上是关于Tomcat8瀹夎锛?瀹夊叏閰嶇疆涓庢€ц兘浼樺寲的主要内容,如果未能解决你的问题,请参考以下文章
寰湇鍔¤縼绉昏锛堜笁锛夛細閰嶇疆涓績SpringCloud Config鎼缓