<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Making Life Simple &#187; tomcat</title>
	<atom:link href="http://www.lalitmehta.com/home/tag/tomcat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lalitmehta.com/home</link>
	<description></description>
	<lastBuildDate>Thu, 19 Jan 2012 09:13:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Starting Tomcat automatically after Linux boots.</title>
		<link>http://www.lalitmehta.com/home/2006/06/01/starting-tomcat-automatically-after-linux-boots/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=starting-tomcat-automatically-after-linux-boots</link>
		<comments>http://www.lalitmehta.com/home/2006/06/01/starting-tomcat-automatically-after-linux-boots/#comments</comments>
		<pubDate>Fri, 02 Jun 2006 04:02:35 +0000</pubDate>
		<dc:creator>lalit</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.lalitmehta.com/home/?p=10</guid>
		<description><![CDATA[If Tomcat was not bundled as part of an operating system distribution, it won&#8217;t have the necessary file(s) to start automatically at system boot time. This describes the steps that should be taken to start Tomcat automatically after Linux boots. 1. Create a Tomcat user Create a group, named tomcat. Create a new non-privileged user [...]]]></description>
			<content:encoded><![CDATA[<p>If Tomcat was not bundled as part of an operating system distribution, it won&#8217;t have the necessary file(s) to start automatically at system boot time. This describes the steps that should be taken to start Tomcat automatically after Linux boots.</p>
<p>1. Create a Tomcat user<br />
Create a group, named tomcat. Create a new non-privileged user (e.g. tomcat)for Tomcat to run as. Ensure that tomcat belongs to the tomcat group. I prefer to keep this user account locked to prevent people trying to log in.</p>
<p>2. Change ownership of Tomcat files<br />
Recursivly change the ownership of the tomcat installation files and directories to the new non-priviliged user<br />
chown -R tomcat &lt;root of tomcat installation&gt;</p>
<p>For all users that need to write files to &lt;tomcat_home&gt;/webapps modify the group permissions to allow this write. eg:<br />
chmod 775 &lt;tomcat_home&gt;/webapps</p>
<p>Any tomcat users should then be added to the tomcat group, allowing them to deploy their files to the webapps directory.</p>
<p>3. Create the Tomcat start-up script:<br />
Create the file /etc/rc.d/init.d/tomcat</p>
<p>Insert the following contents, making sure that:</p>
<p>* JAVA_HOME references the root of the Java development kit directory<br />
* start_tomcat is assigned to the fully qualified path to &lt;tomcat_home&gt;/bin/startup.sh<br />
* stop_tomcat is assigned to the fully qualified path to &lt;tomcat_home)/bin/shutdown.sh</p>
<p>File Contents</p>
<p>#!/bin/sh<br />
#<br />
# Startup script for Tomcat</p>
<p>JAVA_HOME=/usr/java/j2sdk1.4.1_02<br />
export JAVA_HOME<br />
start_tomcat=/usr/local/jakarta-tomcat-4.1.18/bin/startup.sh<br />
stop_tomcat=/usr/local/jakarta-tomcat-4.1.18/bin/shutdown.sh</p>
<p>start() {<br />
echo -n &#8220;Starting tomcat: &#8221;<br />
su -c ${start_tomcat} &#8211; tomcat<br />
echo &#8220;done.&#8221;<br />
}<br />
stop() {<br />
echo -n &#8220;Shutting down tomcat: &#8221;<br />
${stop_tomcat}<br />
echo &#8220;done.&#8221;<br />
}</p>
<p># See how we were called<br />
case &#8220;$1&#8243; in<br />
start)<br />
start<br />
;;<br />
stop)<br />
stop<br />
;;<br />
restart)<br />
stop<br />
sleep 10<br />
start<br />
;;<br />
*)<br />
echo &#8220;Usage: $0 {start|stop|restart}&#8221;<br />
esac</p>
<p>exit 0</p>
<p>4. Test the Tomcat startup script<br />
Test the script by issuing:<br />
[root@localhost]# . /etc/rc.d/init.d/tomcat</p>
<p>Output should be similar to:<br />
Starting tomcat: Using CATALINA_BASE: /opt/tomcat<br />
Using CATALINA_HOME: /opt/tomcat<br />
Using CATALINA_TMPDIR: /opt/tomcat/temp<br />
Using JAVA_HOME: /opt/java<br />
done.</p>
<p>To ensure that tomcat has started try and connect to port 8080 (or whichever you configured Tomcat to use).</p>
<p>5. Link the script into the /etc/rc directories.</p>
<p>Link the script into the /etc/rc directories so that Tomcat is started and stopped when the operating system moves between runlevels. Refer to the file<br />
/etc/inittab for runlevels, but typically Tomcat will be linked in to start on runlevel 3 (Full multi user mode, no X) and runlevel 5 (full multi user with X11). See example below.<br />
[root@l54 rc.d]# cd /etc/rc.d/rc3.d<br />
[root@l54 rc.d]# ln -s ../init.d/tomcat S71tomcat<br />
[root@l54 rc.d]# ln -s ../init.d/tomcat K01tomcat<br />
[root@l54 rc.d]# cd ../rc5.d<br />
[root@l54 rc.d]# ln -s ../init.d/tomcat S71tomcat<br />
[root@l54 rc.d]# ln -s ../init.d/tomcat K01tomcat</p>
<p>NOTE: Which number you use will depend on your local configuration, but obviously Tomcat has to start after network services! Files with an uppercase S indicate daemons that will be started. The number indicates the order in which they are started: low numbers before high. The filenames starting with K indicate daemons that will be shutdown when leaving the runlevel. Typically we like to shut down Tomcat very early in this process.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lalitmehta.com/home/2006/06/01/starting-tomcat-automatically-after-linux-boots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

