{"id":240,"date":"2006-05-22T14:15:00","date_gmt":"2006-05-22T14:15:00","guid":{"rendered":"http:\/\/www.bartbusschots.ie\/blog\/?p=240"},"modified":"2014-08-04T20:40:50","modified_gmt":"2014-08-04T20:40:50","slug":"installing-apache-tomcat-55-on-linux","status":"publish","type":"post","link":"https:\/\/www.bartbusschots.ie\/s\/2006\/05\/22\/installing-apache-tomcat-55-on-linux\/","title":{"rendered":"Installing Apache Tomcat 5.5 on Linux"},"content":{"rendered":"<p>I&#8217;ve previously done a guide on the right way of <a title=\"Guide for Installing Tomcat 5.0 on OS X 10.4 Tiger\" href=\"http:\/\/www.bartbusschots.ie\/blog\/?p=201\">installing Tomcat 5.0 on the Mac<\/a> but things are a little different on Linux so I figured I&#8217;d do another guide. This one is a little less advanced because it only covers running Tomcat as root and not as a non-root user. Depending on how busy I am in the next while I may or may not do a follow-up article on the additional steps needed to run Tomcat as a non-root user. I have tested this procedure on RHEL ES 4 with Tomcat 5.5.17 and the Sun JDK version 1.5.0_6 but it should be the same on all Linux distros and for all 5.X Tomcat versions, the only thing that is likely to change is the location of <code>$JAVA_HOME<\/code>. <span style=\"color:#ff0000\">Correction, the startup script included is for Redhat based distros only (RHEL, Fedora, CentOS etc).<\/span><\/p>\n<p><!--more--><\/p>\n<h2>Before We Begin<\/h2>\n<p>Before starting you need to make sure you have the 1.5 version of Sun&#8217;s JDK installed. If you&#8217;re on an RPM based Linux install running on x86 the simplest thing to do is to grab the RPM form java.sun.com. How ever you choose to install the Sun JVM you will need to know where it installs to for creating the <code>$JAVA_HOME<\/code> environment variable later. If you get it from the Sun RPM it will install in <code>\/usr\/java\/<\/code> so at the time of writing that means the most current JDK will install to <code>\/usr\/java\/jdk1.5.0_06\/<\/code>. If you are using a Debian based distro (like Ubuntu) you might find my guide on <a title=\"The CORRECT way to install Sun Java in Debian\/Ubuntu\" href=\"http:\/\/www.minds.nuim.ie\/~voyager\/blog\/index.php?\/archives\/24-The-CORRECT-way-to-install-Sun-Java-on-DebianUbuntu.html\">installing the Sun JDK on Debian<\/a> helpful.<\/p>\n<h2>Step 1 &#8211; Install Tomcat Files<\/h2>\n<p>The first step is to get the binary distribution of Tomcat from the Apache Site (you just need the Core package). When you get this extract it and copy the entire folder it contains to <code>\/usr\/local<\/code>. The sequence of commands below assumes that you got the <code>.tar.gz<\/code> version of the core package for Tomcat 5.5.17. You&#8217;ll need to adjust slightly for other versions. It is also helpful to create a simlink in <code>\/usr\/local<\/code> called <code>tomcat<\/code> that you will always have pointing at your current tomcat install, makes upgrades easier.<\/p>\n<pre>\r\n[bbusschots@honeysuckle ~]$ tar -xzf apache-tomcat-5.5.17.tar.gz\r\n[bbusschots@honeysuckle ~]$ sudo mv apache-tomcat-5.5.17 \/usr\/local\/\r\n[bbusschots@honeysuckle ~]$ cd \/usr\/local\/\r\n[bbusschots@honeysuckle local]$ sudo ln -s apache-tomcat-5.5.17\/ tomcat\r\n<\/pre>\n<p><strong>Note: <\/strong>I use <code>sudo<\/code> for commands that need to be run as root, if your system is not set up to use <code>sudo<\/code> like this then do everything as <code>root<\/code> and leave off the <code>sudo<\/code> from the commands above.<\/p>\n<p>At this point we are basically done. If you want to be able to start and stop tomcat from the command line you&#8217;ll need to set up environment variables or you can skip that step and set Tomcat up as a service instead. The choice is yours. On a production environment you really should set Tomcat up as a service though.<\/p>\n<h2>Step 2a &#8211; Setting Environment Variables (Optional):<\/h2>\n<p>If you choose to go this route you will need to set the following two environment variables in your shell (because each shell is different I won&#8217;t go in to how you do that in this article):<\/p>\n<ol>\n<li><code>JAVA_HOME<\/code> &#8211; needs to point to your Java install. (If you used the latest Sun RPM<br \/>\n that will be <code>\/usr\/java\/jdk1.5.0_6<\/code>)<\/li>\n<li><code>CATALINA_HOME<\/code> &#8211; should be set to <code>\/usr\/local\/tomcat<\/code><\/li>\n<\/ol>\n<p>You are now ready to start Tomcat with the command <code>\/usr\/local\/tomcat\/bin\/startup.sh<\/code> and stop Tomcat with the command <code>\/usr\/local\/tomcat\/bin\/shutdown.sh<\/code>. Tomcat will not start automatically at boot though.<\/p>\n<h2>Step 2b &#8211; Setting Tomcat up as a Service (Optional):<\/h2>\n<p>If you want Tomcat to start automatically on boot then you need to set it up as a service. To do this you need to copy the code below and save it as a file called <code>tomcat<\/code> in the folder <code>\/etc\/init.d<\/code>:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# This is the init script for starting up the\r\n#  Jakarta Tomcat server\r\n#\r\n# chkconfig: 345 91 10\r\n# description: Starts and stops the Tomcat daemon.\r\n#\r\n\r\n# Source function library.\r\n. \/etc\/rc.d\/init.d\/functions\r\n\r\n# Get config.\r\n. \/etc\/sysconfig\/network\r\n\r\n# Check that networking is up.\r\n&#x5B; &quot;${NETWORKING}&quot; = &quot;no&quot; ] &amp;&amp; exit 0\r\n\r\ntomcat=\/usr\/local\/tomcat\r\nstartup=$tomcat\/bin\/startup.sh\r\nshutdown=$tomcat\/bin\/shutdown.sh\r\nexport JAVA_HOME=\/usr\/java\/jdk1.5.0_6\r\n\r\nstart(){\r\n echo -n $&quot;Starting Tomcat service: &quot;\r\n #daemon -c\r\n $startup\r\n RETVAL=$?\r\n echo\r\n}\r\n\r\nstop(){\r\n action $&quot;Stopping Tomcat service: &quot; $shutdown \r\n RETVAL=$?\r\n echo\r\n}\r\n\r\nrestart(){\r\n  stop\r\n  start\r\n}\r\n\r\n\r\n# See how we were called.\r\ncase &quot;$1&quot; in\r\nstart)\r\n start\r\n ;;\r\nstop)\r\n stop\r\n ;;\r\nstatus)\r\n      # This doesn&#039;t work ;)\r\n status tomcat\r\n ;;\r\nrestart)\r\n restart\r\n ;;\r\n*)\r\n echo $&quot;Usage: $0 {start|stop|status|restart}&quot;\r\n exit 1\r\nesac\r\n\r\nexit 0\r\n<\/pre>\n<p>You may have to change the value for <code>JAVA_HOME<\/code> if your JDK is in a different location to mine. You then need to make the file executable with the command:<\/p>\n<pre>sudo chmod +x \/etc\/init.d\/tomcat<\/pre>\n<p>And finally you need to set it to start at boot with the command:<\/p>\n<pre>sudo chkconfig --add tomcat<\/pre>\n<p>You now have a working Tomcat install that will start it self at boot time. You can also interact with it using the <code>service<\/code> command to start, stop, restart and see the status of the service at any time. E.g.<\/p>\n<pre>\r\nsudo service tomcat start\r\nsudo service tomcat satus\r\nsudo service tomcat stop\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve previously done a guide on the right way of installing Tomcat 5.0 on the Mac but things are a little different on Linux so I figured I&#8217;d do another guide. This one is a little less advanced because it only covers running Tomcat as root and not as a non-root user. Depending on how [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12,446],"tags":[422,5,412,408,421],"series":[],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-computers-tech","category-sysadmin","tag-apache-tomcat","tag-java","tag-linux","tag-open-source","tag-web-server"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7t9xK-3S","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":1,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"predecessor-version":[{"id":7404,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/240\/revisions\/7404"}],"wp:attachment":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/tags?post=240"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/series?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}