{"id":6379,"date":"2016-10-13T08:41:07","date_gmt":"2016-10-13T00:41:07","guid":{"rendered":"http:\/\/rmohan.com\/?p=6379"},"modified":"2016-10-13T08:41:58","modified_gmt":"2016-10-13T00:41:58","slug":"install-tomcat-9-on-centos-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6379","title":{"rendered":"Install Tomcat 9 on Centos 7"},"content":{"rendered":"<p><strong>Install Tomcat 9 on Centos 7<\/strong><\/p>\n<p>cd \/opt\/<br \/>\nwget &#8211;no-cookies &#8211;no-check-certificate &#8211;header &#8220;Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie&#8221; &#8220;http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u101-b13\/jdk-8u101-linux-x64.tar.gz&#8221;<br \/>\ntar -zxvf jdk-8u101-linux-x64.tar.gz<br \/>\nalternatives &#8211;install \/usr\/bin\/java java \/opt\/jdk1.8.0_101\/bin\/java 2<br \/>\nalternatives &#8211;config java<br \/>\njava -version<br \/>\nvi \/etc\/profile.d\/java.sh<br \/>\nexport JAVA_HOME=\/opt\/jdk1.8.0_101<br \/>\nexport JRE_HOME=\/opt\/jdk1.8.0_101\/jre<br \/>\nexport PATH=$PATH:\/opt\/jdk1.8.0_101\/bin:\/opt\/jdk1.8.0_101\/jre\/bin<br \/>\nchmod +x \/etc\/profile.d\/java.sh<br \/>\nsource \/etc\/profile.d\/java.sh<br \/>\nexport<\/p>\n<p>cd \/usr\/local<br \/>\nwget http:\/\/www.us.apache.org\/dist\/tomcat\/tomcat-9\/v9.0.0.M1\/bin\/apache-tomcat-9.0.0.M1.tar.gz<br \/>\nwget http:\/\/download.nus.edu.sg\/mirror\/apache\/tomcat\/tomcat-9\/v9.0.0.M11\/bin\/apache-tomcat-9.0.0.M11.tar.gz<br \/>\ntar -zxvf apache-tomcat-9.0.0.M11.tar.gz<br \/>\ncd apache-tomcat-9.0.0.M11<br \/>\ncd bin\/<br \/>\n.\/startup.sh<br \/>\nps -ef | grep java<br \/>\n.\/shutdown.sh<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>[root@clusterserver1 conf]# cat server.xml<br \/>\n&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br \/>\n&lt;!&#8211;<br \/>\nLicensed to the Apache Software Foundation (ASF) under one or more<br \/>\ncontributor license agreements.\u00a0 See the NOTICE file distributed with<br \/>\nthis work for additional information regarding copyright ownership.<br \/>\nThe ASF licenses this file to You under the Apache License, Version 2.0<br \/>\n(the &#8220;License&#8221;); you may not use this file except in compliance with<br \/>\nthe License.\u00a0 You may obtain a copy of the License at<\/p>\n<p>http:\/\/www.apache.org\/licenses\/LICENSE-2.0<\/p>\n<p>Unless required by applicable law or agreed to in writing, software<br \/>\ndistributed under the License is distributed on an &#8220;AS IS&#8221; BASIS,<br \/>\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br \/>\nSee the License for the specific language governing permissions and<br \/>\nlimitations under the License.<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211; Note:\u00a0 A &#8220;Server&#8221; is not itself a &#8220;Container&#8221;, so you may not<br \/>\ndefine subcomponents such as &#8220;Valves&#8221; at this level.<br \/>\nDocumentation at \/docs\/config\/server.html<br \/>\n&#8211;&gt;<br \/>\n&lt;Server port=&#8221;8005&#8243; shutdown=&#8221;SHUTDOWN&#8221;&gt;<br \/>\n&lt;Listener className=&#8221;org.apache.catalina.startup.VersionLoggerListener&#8221; \/&gt;<br \/>\n&lt;!&#8211; Security listener. Documentation at \/docs\/config\/listeners.html<br \/>\n&lt;Listener className=&#8221;org.apache.catalina.security.SecurityListener&#8221; \/&gt;<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211;APR library loader. Documentation at \/docs\/apr.html &#8211;&gt;<br \/>\n&lt;Listener className=&#8221;org.apache.catalina.core.AprLifecycleListener&#8221; SSLEngine=&#8221;on&#8221; \/&gt;<br \/>\n&lt;!&#8211; Prevent memory leaks due to use of particular java\/javax APIs&#8211;&gt;<br \/>\n&lt;Listener className=&#8221;org.apache.catalina.core.JreMemoryLeakPreventionListener&#8221; \/&gt;<br \/>\n&lt;Listener className=&#8221;org.apache.catalina.mbeans.GlobalResourcesLifecycleListener&#8221; \/&gt;<br \/>\n&lt;Listener className=&#8221;org.apache.catalina.core.ThreadLocalLeakPreventionListener&#8221; \/&gt;<\/p>\n<p>&lt;!&#8211; Global JNDI resources<br \/>\nDocumentation at \/docs\/jndi-resources-howto.html<br \/>\n&#8211;&gt;<br \/>\n&lt;GlobalNamingResources&gt;<br \/>\n&lt;!&#8211; Editable user database that can also be used by<br \/>\nUserDatabaseRealm to authenticate users<br \/>\n&#8211;&gt;<br \/>\n&lt;Resource name=&#8221;UserDatabase&#8221; auth=&#8221;Container&#8221;<br \/>\ntype=&#8221;org.apache.catalina.UserDatabase&#8221;<br \/>\ndescription=&#8221;User database that can be updated and saved&#8221;<br \/>\nfactory=&#8221;org.apache.catalina.users.MemoryUserDatabaseFactory&#8221;<br \/>\npathname=&#8221;conf\/tomcat-users.xml&#8221; \/&gt;<br \/>\n&lt;\/GlobalNamingResources&gt;<\/p>\n<p>&lt;Service name=&#8221;Catalina_2&#8243;&gt;<br \/>\n&lt;Connector port=&#8221;80&#8243; protocol=&#8221;HTTP\/1.1&#8243; connectionTimeout=&#8221;20000&#8243; redirectPort=&#8221;443&#8243; \/&gt;<br \/>\n&lt;Connector port=&#8221;8010&#8243; protocol=&#8221;AJP\/1.3&#8243; redirectPort=&#8221;443&#8243; \/&gt;<br \/>\n&lt;Engine name=&#8221;Catalina_2&#8243; defaultHost=&#8221;localhost&#8221;&gt;<br \/>\n&lt;Realm className=&#8221;org.apache.catalina.realm.LockOutRealm&#8221;&gt;<br \/>\n&lt;Realm className=&#8221;org.apache.catalina.realm.UserDatabaseRealm&#8221; resourceName=&#8221;UserDatabase&#8221;\/&gt;<br \/>\n&lt;\/Realm&gt;<br \/>\n&lt;Host name=&#8221;localhost&#8221;\u00a0 appBase=&#8221;webapps_2&#8243; unpackWARs=&#8221;true&#8221; autoDeploy=&#8221;true&#8221;&gt;<br \/>\n&lt;Valve className=&#8221;org.apache.catalina.valves.AccessLogValve&#8221; directory=&#8221;logs&#8221;<br \/>\nprefix=&#8221;localhost_access_log.&#8221; suffix=&#8221;.txt&#8221;<br \/>\npattern=&#8221;%h %l %u %t &amp;quot;%r&amp;quot; %s %b&#8221; \/&gt;<br \/>\n&lt;\/Host&gt;<br \/>\n&lt;\/Engine&gt;<br \/>\n&lt;\/Service&gt;<\/p>\n<p>&lt;!&#8211; A &#8220;Service&#8221; is a collection of one or more &#8220;Connectors&#8221; that share<br \/>\na single &#8220;Container&#8221; Note:\u00a0 A &#8220;Service&#8221; is not itself a &#8220;Container&#8221;,<br \/>\nso you may not define subcomponents such as &#8220;Valves&#8221; at this level.<br \/>\nDocumentation at \/docs\/config\/service.html<br \/>\n&#8211;&gt;<br \/>\n&lt;Service name=&#8221;Catalina&#8221;&gt;<\/p>\n<p>&lt;!&#8211;The connectors can use a shared executor, you can define one or more named thread pools&#8211;&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Executor name=&#8221;tomcatThreadPool&#8221; namePrefix=&#8221;catalina-exec-&#8221;<br \/>\nmaxThreads=&#8221;150&#8243; minSpareThreads=&#8221;4&#8243;\/&gt;<br \/>\n&#8211;&gt;<\/p>\n<p>&lt;!&#8211; A &#8220;Connector&#8221; represents an endpoint by which requests are received<br \/>\nand responses are returned. Documentation at :<br \/>\nJava HTTP Connector: \/docs\/config\/http.html<br \/>\nJava AJP\u00a0 Connector: \/docs\/config\/ajp.html<br \/>\nAPR (HTTP\/AJP) Connector: \/docs\/apr.html<br \/>\nDefine a non-SSL\/TLS HTTP\/1.1 Connector on port 8080<br \/>\n&#8211;&gt;<br \/>\n&lt;Connector port=&#8221;8080&#8243; protocol=&#8221;HTTP\/1.1&#8243;<br \/>\nconnectionTimeout=&#8221;20000&#8243;<br \/>\nredirectPort=&#8221;8443&#8243; \/&gt;<br \/>\n&lt;!&#8211; A &#8220;Connector&#8221; using the shared thread pool&#8211;&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Connector executor=&#8221;tomcatThreadPool&#8221;<br \/>\nport=&#8221;8080&#8243; protocol=&#8221;HTTP\/1.1&#8243;<br \/>\nconnectionTimeout=&#8221;20000&#8243;<br \/>\nredirectPort=&#8221;8443&#8243; \/&gt;<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211; Define a SSL\/TLS HTTP\/1.1 Connector on port 8443<br \/>\nThis connector uses the NIO implementation with the JSSE engine. When<br \/>\nusing the JSSE engine, the JSSE configuration attributes must be used.<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Connector port=&#8221;8443&#8243; protocol=&#8221;org.apache.coyote.http11.Http11NioProtocol&#8221;<br \/>\nmaxThreads=&#8221;150&#8243; SSLEnabled=&#8221;true&#8221;&gt;<br \/>\n&lt;SSLHostConfig&gt;<br \/>\n&lt;Certificate certificateKeystoreFile=&#8221;conf\/localhost-rsa.jks&#8221;<br \/>\ntype=&#8221;RSA&#8221; \/&gt;<br \/>\n&lt;\/SSLHostConfig&gt;<br \/>\n&lt;\/Connector&gt;<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211; Define a SSL\/TLS HTTP\/1.1 Connector on port 8443 with HTTP\/2<br \/>\nThis connector uses the APR\/native implementation. When using the<br \/>\nAPR\/native implementation or the OpenSSL engine with NIO or NIO2 then<br \/>\nthe OpenSSL configuration attributes must be used.<br \/>\n&#8211;&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Connector port=&#8221;8443&#8243; protocol=&#8221;org.apache.coyote.http11.Http11AprProtocol&#8221;<br \/>\nmaxThreads=&#8221;150&#8243; SSLEnabled=&#8221;true&#8221; &gt;<br \/>\n&lt;UpgradeProtocol className=&#8221;org.apache.coyote.http2.Http2Protocol&#8221; \/&gt;<br \/>\n&lt;SSLHostConfig&gt;<br \/>\n&lt;Certificate certificateKeyFile=&#8221;conf\/localhost-rsa-key.pem&#8221;<br \/>\ncertificateFile=&#8221;conf\/localhost-rsa-cert.pem&#8221;<br \/>\ncertificateChainFile=&#8221;conf\/localhost-rsa-chain.pem&#8221;<br \/>\ntype=&#8221;RSA&#8221; \/&gt;<br \/>\n&lt;\/SSLHostConfig&gt;<br \/>\n&lt;\/Connector&gt;<br \/>\n&#8211;&gt;<\/p>\n<p>&lt;!&#8211; Define an AJP 1.3 Connector on port 8009 &#8211;&gt;<br \/>\n&lt;Connector port=&#8221;8009&#8243; protocol=&#8221;AJP\/1.3&#8243; redirectPort=&#8221;8443&#8243; \/&gt;<\/p>\n<p>&lt;!&#8211; An Engine represents the entry point (within Catalina) that processes<br \/>\nevery request.\u00a0 The Engine implementation for Tomcat stand alone<br \/>\nanalyzes the HTTP headers included with the request, and passes them<br \/>\non to the appropriate Host (virtual host).<br \/>\nDocumentation at \/docs\/config\/engine.html &#8211;&gt;<\/p>\n<p>&lt;!&#8211; You should set jvmRoute to support load-balancing via AJP ie :<br \/>\n&lt;Engine name=&#8221;Catalina&#8221; defaultHost=&#8221;localhost&#8221; jvmRoute=&#8221;jvm1&#8243;&gt;<br \/>\n&#8211;&gt;<br \/>\n&lt;Engine name=&#8221;Catalina&#8221; defaultHost=&#8221;localhost&#8221;&gt;<\/p>\n<p>&lt;!&#8211;For clustering, please take a look at documentation at:<br \/>\n\/docs\/cluster-howto.html\u00a0 (simple how to)<br \/>\n\/docs\/config\/cluster.html (reference documentation) &#8211;&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Cluster className=&#8221;org.apache.catalina.ha.tcp.SimpleTcpCluster&#8221;\/&gt;<br \/>\n&#8211;&gt;<\/p>\n<p>&lt;!&#8211; Use the LockOutRealm to prevent attempts to guess user passwords<br \/>\nvia a brute-force attack &#8211;&gt;<br \/>\n&lt;Realm className=&#8221;org.apache.catalina.realm.LockOutRealm&#8221;&gt;<br \/>\n&lt;!&#8211; This Realm uses the UserDatabase configured in the global JNDI<br \/>\nresources under the key &#8220;UserDatabase&#8221;.\u00a0 Any edits<br \/>\nthat are performed against this UserDatabase are immediately<br \/>\navailable for use by the Realm.\u00a0 &#8211;&gt;<br \/>\n&lt;Realm className=&#8221;org.apache.catalina.realm.UserDatabaseRealm&#8221;<br \/>\nresourceName=&#8221;UserDatabase&#8221;\/&gt;<br \/>\n&lt;\/Realm&gt;<\/p>\n<p>&lt;Host name=&#8221;localhost&#8221;\u00a0 appBase=&#8221;webapps&#8221;<br \/>\nunpackWARs=&#8221;true&#8221; autoDeploy=&#8221;true&#8221;&gt;<\/p>\n<p>&lt;!&#8211; SingleSignOn valve, share authentication between web applications<br \/>\nDocumentation at: \/docs\/config\/valve.html &#8211;&gt;<br \/>\n&lt;!&#8211;<br \/>\n&lt;Valve className=&#8221;org.apache.catalina.authenticator.SingleSignOn&#8221; \/&gt;<br \/>\n&#8211;&gt;<\/p>\n<p>&lt;!&#8211; Access log processes all example.<br \/>\nDocumentation at: \/docs\/config\/valve.html<br \/>\nNote: The pattern used is equivalent to using pattern=&#8221;common&#8221; &#8211;&gt;<br \/>\n&lt;Valve className=&#8221;org.apache.catalina.valves.AccessLogValve&#8221; directory=&#8221;logs&#8221;<br \/>\nprefix=&#8221;localhost_access_log&#8221; suffix=&#8221;.txt&#8221;<br \/>\npattern=&#8221;%h %l %u %t &amp;quot;%r&amp;quot; %s %b&#8221; \/&gt;<\/p>\n<p>&lt;\/Host&gt;<br \/>\n&lt;\/Engine&gt;<br \/>\n&lt;\/Service&gt;<br \/>\n&lt;\/Server&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install Tomcat 9 on Centos 7<\/p>\n<p>cd \/opt\/ wget &#8211;no-cookies &#8211;no-check-certificate &#8211;header &#8220;Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie&#8221; &#8220;http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u101-b13\/jdk-8u101-linux-x64.tar.gz&#8221; tar -zxvf jdk-8u101-linux-x64.tar.gz alternatives &#8211;install \/usr\/bin\/java java \/opt\/jdk1.8.0_101\/bin\/java 2 alternatives &#8211;config java java -version vi \/etc\/profile.d\/java.sh export JAVA_HOME=\/opt\/jdk1.8.0_101 export JRE_HOME=\/opt\/jdk1.8.0_101\/jre export PATH=$PATH:\/opt\/jdk1.8.0_101\/bin:\/opt\/jdk1.8.0_101\/jre\/bin chmod +x \/etc\/profile.d\/java.sh source \/etc\/profile.d\/java.sh export<\/p>\n<p>cd \/usr\/local wget http:\/\/www.us.apache.org\/dist\/tomcat\/tomcat-9\/v9.0.0.M1\/bin\/apache-tomcat-9.0.0.M1.tar.gz wget http:\/\/download.nus.edu.sg\/mirror\/apache\/tomcat\/tomcat-9\/v9.0.0.M11\/bin\/apache-tomcat-9.0.0.M11.tar.gz tar -zxvf apache-tomcat-9.0.0.M11.tar.gz cd apache-tomcat-9.0.0.M11 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6379"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6379"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6379\/revisions"}],"predecessor-version":[{"id":6384,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6379\/revisions\/6384"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}