{"id":272,"date":"2015-09-07T16:12:54","date_gmt":"2015-09-07T16:12:54","guid":{"rendered":"http:\/\/onlinelab.info\/?p=272"},"modified":"2015-09-07T16:12:54","modified_gmt":"2015-09-07T16:12:54","slug":"install-apache-tomcat-8-on-centos-7-rhel-7","status":"publish","type":"post","link":"https:\/\/www.asianux.org.vn\/index.php\/2015\/09\/07\/install-apache-tomcat-8-on-centos-7-rhel-7\/","title":{"rendered":"Install Apache Tomcat 8 on CentOS 7 \/ RHEL 7"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6582 size-thumbnail\" src=\"http:\/\/www.itzgeek.com\/wp-content\/uploads\/2014\/03\/Tomcat-Logo-150x150.jpg\" alt=\"Tomcat Logo\" width=\"150\" height=\"150\" title=\"\"><\/p>\n<p>Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a \u201cpure Java\u201d HTTP web server environment for running the Java codes. Apache Tomcat includes tools for configuration and management, but can also be configured by editing XML configuration files.<\/p>\n<p>Here is the step by step guide to install Apache Tomcat 8.0 on <a href=\"http:\/\/www.itzgeek.com\/tag\/centos-7\" target=\"_blank\" rel=\"nofollow noopener\">RHEL 7 \/ CentOS 7<\/a>.<\/p>\n<p>Open Terminal.<\/p>\n<p>Switch to root user.<\/p>\n<h3><strong>Install OpenJDK:<\/strong><\/h3>\n<p>Tomcat requires to have java installed on your machine, you can either have <a title=\"How to install Java SDK 1.8 on RHEL 7\/ CentOS 7\" href=\"http:\/\/www.itzgeek.com\/how-tos\/linux\/centos-how-tos\/how-to-install-java-sdk-1-8-on-rhel-7-centos-7.html\" target=\"_blank\" rel=\"nofollow noopener\">Oracle JDK<\/a> or OpenJDK installed on your machine. Here i used the openjdk, lets install openjdk by issuing the following command.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# yum install java-1.7.0<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>You can also verify it, by issuing the following command.<\/p>\n<div class=\"command\">[root@server ~]# java -version<br \/>\njava version \u201c1.7.0_65\u2033<br \/>\nOpenJDK Runtime Environment (rhel-2.5.1.2.el7_0-x86_64 u65-b17)<br \/>\nOpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)<\/div>\n<p><strong>Download &amp; Setup Apache Tomcat:<\/strong><\/p>\n<p>Download the latest version of the Apache Tomcat from the website and save it on your home directory.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# wget http:\/\/mirror.nexcess.net\/apache\/tomcat\/tomcat-8\/v8.0.9\/bin\/apache-tomcat-8.0.9.tar.gz<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Download the MD5 file.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# wget --no-check-certificate https:\/\/www.apache.org\/dist\/tomcat\/tomcat-8\/v8.0.9\/bin\/apache-tomcat-8.0.9.tar.gz.md5<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Verify the md5 check sum of the downloaded Tomcat archive with check sum provided by Apache Tomcat.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# cat apache-tomcat-8.0.9.tar.gz.md5\n82140943a894d582e5b34eff79b8c776 *apache-tomcat-8.0.9.tar.gz\n\u00a0\n[root@server ~]#\u00a0md5sum apache-tomcat-8.0.9.tar.gz\n82140943a894d582e5b34eff79b8c776\u00a0 apache-tomcat-8.0.9.tar.gz<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>If both matches, extract the the tomcat on to your desired (\/var\/local) directory.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# tar -zxvf apache-tomcat-8.0.9.tar.gz -C \/var\/local\/<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Controlling Apache Tomcat:<\/strong><\/h4>\n<p>Apache Tomcat can be started and stopped by the script which comes with package, start the Apache Tomcat.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# \/var\/local\/apache-tomcat-8.0.9\/bin\/startup.sh<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>you will get the following output.<\/p>\n<div class=\"command\">Using CATALINA_BASE:\u00a0\u00a0 \/var\/local\/apache-tomcat-8.0.9<br \/>\nUsing CATALINA_HOME:\u00a0\u00a0 \/var\/local\/apache-tomcat-8.0.9<br \/>\nUsing CATALINA_TMPDIR: \/var\/local\/apache-tomcat-8.0.9\/temp<br \/>\nUsing JRE_HOME:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/usr<br \/>\nUsing CLASSPATH:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/local\/apache-tomcat-8.0.9\/bin\/bootstrap.jar:\/var\/local\/apache-tomcat-8.0.9\/bin\/tomcat-juli.jar<br \/>\nTomcat started.<\/div>\n<p>You can verify the service running, by default tomcat runs on port no 8080<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# netstat -antup | grep 8080\ntcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      2476\/java<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Open the web browser and point to http:\/\/ipaddress:8080<\/p>\n<figure id=\"attachment_7237\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7237\" src=\"http:\/\/www.itzgeek.com\/wp-content\/uploads\/2014\/07\/CentOS-7-Apache-Tomcat-8-Default-Page.jpg\" alt=\"CentOS 7 - Apache Tomcat 8 Default Page\" width=\"640\" height=\"475\" title=\"\"><figcaption class=\"wp-caption-text\">CentOS 7 \u2013 Apache Tomcat 8 Default Page<\/figcaption><\/figure>\n<p>Stop the Apache Tomcat.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# \/var\/local\/apache-tomcat-8.0.9\/bin\/shutdown.sh<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Managing the Apache Tomcat:<\/strong><\/h4>\n<p>Tomcat can be managed through the web-manager, the following can be done through that.<br \/>\nDeploy new application, deploy new application on specified context, list the active or in active applications, start and stop the web applications.<\/p>\n<p>Web manager is password protected, requires user name and password to access. Only the user with the \u201cmanager-gui\u201d role is allowed to access, these users and roles are defined in tomcat-users.xml. By default \u201cmanager-gui\u201d role not defined that file, we need to add it manually.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">[root@server ~]# vi \/var\/local\/apache-tomcat-8.0.9\/conf\/tomcat-users.xml<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Place the following two lines just above the last line.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"xml\">&lt;role rolename=\"manager-gui\"\/&gt;\n&lt;user username=\"tomcat\" password=\"tomcat\" roles=\"manager-gui\"\/&gt;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Start the tomcat, now tomcat user have access to the web manager.<\/p>\n<figure id=\"attachment_7236\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7236\" src=\"http:\/\/www.itzgeek.com\/wp-content\/uploads\/2014\/07\/CentOS-7-Apache-Tomcat-8-App-Manager.jpg\" alt=\"CentOS 7 - Apache Tomcat 8 App Manager\" width=\"640\" height=\"475\" title=\"\"><figcaption class=\"wp-caption-text\">CentOS 7 \u2013 Apache Tomcat 8 App Manager<\/figcaption><\/figure>\n<p>Same like, you can define the <a href=\"http:\/\/tomcat.apache.org\/tomcat-7.0-doc\/manager-howto.html#Configuring_Manager_Application_Access\" target=\"_blank\" rel=\"nofollow noopener\">other roles<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a \u201cpure&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-272","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts\/272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/comments?post=272"}],"version-history":[{"count":0,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts\/272\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/media?parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/categories?post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/tags?post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}