<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>drwxr- -r- - &#187; linux</title>
	<atom:link href="http://edwardaux.wordpress.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://edwardaux.wordpress.com</link>
	<description>/dev/random</description>
	<lastBuildDate>Wed, 17 Jan 2007 23:09:20 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='edwardaux.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0efbe74b7a4ca52db819aeb3f17d4bd8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>drwxr- -r- - &#187; linux</title>
		<link>http://edwardaux.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://edwardaux.wordpress.com/osd.xml" title="drwxr- -r- -" />
		<item>
		<title>Tomcat 5.0 and jmx.jar in Eclipse</title>
		<link>http://edwardaux.wordpress.com/2007/01/16/tomcat-50-and-jmxjar-in-eclipse/</link>
		<comments>http://edwardaux.wordpress.com/2007/01/16/tomcat-50-and-jmxjar-in-eclipse/#comments</comments>
		<pubDate>Tue, 16 Jan 2007 02:30:48 +0000</pubDate>
		<dc:creator>edwardaux</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://edwardaux.wordpress.com/2007/01/16/tomcat-50-and-jmxjar-in-eclipse/</guid>
		<description><![CDATA[I used to use the sysdeo Tomcat plugin in Eclipse for my development, but someone suggested that I take a look at the Eclipse Web Tools project, which is an application server feature for Eclipse.  It seems like it is the mechanism through which Eclipse is planning to support application servers in the future, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=edwardaux.wordpress.com&blog=398350&post=11&subd=edwardaux&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I used to use the sysdeo Tomcat plugin in Eclipse for my development, but someone suggested that I take a look at the <a href="http://www.eclipse.org/webtools/">Eclipse Web Tools</a> project, which is an application server feature for Eclipse.  It seems like it is the mechanism through which Eclipse is planning to support application servers in the future, so I thought it would be worth a look.</p>
<p>However, once I got it installed, I ran into a problem that is mentioned a few times on various sites on the web, but with few solutions.  When I tried to run the application server, I got the following message:<br />
<code><br />
Due to new licensing guidelines mandated by the Apache Software Foundation Board of Directors, a JMX implementation can no longer be distributed with the Apache Tomcat binaries. As a result, you must download a JMX 1.2 implementation (such as the Sun Reference Implementation) and copy the JAR containing the API and implementation of the JMX specification to: ${catalina.home}/bin/jmx.jar<br />
</code></p>
<p>This article describes the workaround that I discovered to make Tomcat 5.0 work correctly inside Eclipse.<br />
<span id="more-11"></span><br />
But first, let&#8217;s step back to find out how I arrived at my current state.</p>
<p>From the <a href="http://www.eclipse.org/webtools/">Eclipse Web Tools home page</a>, they have a link on the top-right hand side that takes you to the latest download page.  For me, I used <a href="http://download.eclipse.org/webtools/downloads/drops/R1.5/R-1.5.2-200610261841/">Version 1.5.2</a> of the WTP.  </p>
<p>On that page they conveniently provide a link where you could download, in one thumping big file, <a href="http://www.eclipse.org/downloads/download.php?file=/webtools/downloads/drops/R1.5/R-1.5.2-200610261841/wtp-all-in-one-sdk-R-1.5.2-200610261841-win32.zip">a single zip</a> that contains Eclipse 3.2.1, WTP 1.5.2 and all the other pre-requisites (beware, it is about 200MB!)</p>
<p>On my Ubuntu machine, I originally installed eclipse using apt-get, which installs into <code>/usr/share/eclipse</code>.  To preserve all my existing shortcuts, I just renamed that directory to be <code>/usr/share/eclipse3.1</code>, and unzipped the new eclipse into <code>/usr/share/eclipse</code>.  I am not really sure if that is the sanctioned way (probably not), but it worked perfectly for me.</p>
<p>Before you create a new project, you will need to go into the Windows/Preferences menu item, and open the Server settings dialog. In here, add a new Server Runtime for Tomcat 5.0 and point it to your default tomcat directory (<code>/usr/share /tomcat5</code> for me).</p>
<p><img src='http://edwardaux.files.wordpress.com/2007/01/newserverruntime1.png' alt='newserverruntime1.png' /><br />
<img src='http://edwardaux.files.wordpress.com/2007/01/newserverruntime2.png' alt='newserverruntime2.png' /></p>
<p>From there it was a simple matter of creating a new Dynamic Web Project, where it asks me which &#8220;Target Runtime&#8221; I wanted to deploy into, and I chose the newly created Tomcat 5.0 runtime.</p>
<p>I then developed a simple web application, and when I attempted to start the Tomcat instance, I got the above error message.  Searching on the web didn&#8217;t give me too much love, and interestingly, I don&#8217;t get this message when I start Tomcat using <code>/etc/init.d/tomcat</code>.  </p>
<p>Anyway, the solution I found was to edit the runtime classpath of the application server (from the Run/Run&#8230; menu) to include the following entries:</p>
<p><img src='http://edwardaux.files.wordpress.com/2007/01/run.png' alt='run.png' /></p>
<p>Once I applied those changes, and restarted my application server, everything was working like a champion.  </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/edwardaux.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/edwardaux.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/edwardaux.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/edwardaux.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/edwardaux.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/edwardaux.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/edwardaux.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/edwardaux.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/edwardaux.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/edwardaux.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/edwardaux.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/edwardaux.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=edwardaux.wordpress.com&blog=398350&post=11&subd=edwardaux&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://edwardaux.wordpress.com/2007/01/16/tomcat-50-and-jmxjar-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78ca0337f048eead2861b667cc627041?s=96&#38;d=identicon" medium="image">
			<media:title type="html">edwardaux</media:title>
		</media:content>

		<media:content url="http://edwardaux.files.wordpress.com/2007/01/newserverruntime1.png" medium="image">
			<media:title type="html">newserverruntime1.png</media:title>
		</media:content>

		<media:content url="http://edwardaux.files.wordpress.com/2007/01/newserverruntime2.png" medium="image">
			<media:title type="html">newserverruntime2.png</media:title>
		</media:content>

		<media:content url="http://edwardaux.files.wordpress.com/2007/01/run.png" medium="image">
			<media:title type="html">run.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Tracking spam origination using qmail and vpopmail</title>
		<link>http://edwardaux.wordpress.com/2007/01/13/tracking-spam-origination-using-qmail-and-vpopmail/</link>
		<comments>http://edwardaux.wordpress.com/2007/01/13/tracking-spam-origination-using-qmail-and-vpopmail/#comments</comments>
		<pubDate>Sat, 13 Jan 2007 03:39:32 +0000</pubDate>
		<dc:creator>edwardaux</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[vpopmail]]></category>

		<guid isPermaLink="false">http://edwardaux.wordpress.com/2007/01/13/tracking-spam-origination-using-qmail-and-vpopmail/</guid>
		<description><![CDATA[One of the challenges on the web at the moment is that many sites want you to register a &#8220;free&#8221; userid just to do the most mundane thing (such as downloading a file, viewing a picture, etc).  While I don&#8217;t have a problem with that requirement in general, I am often quite sceptical about [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=edwardaux.wordpress.com&blog=398350&post=10&subd=edwardaux&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>One of the challenges on the web at the moment is that many sites want you to register a &#8220;free&#8221; userid just to do the most mundane thing (such as downloading a file, viewing a picture, etc).  While I don&#8217;t have a problem with that requirement in general, I am often quite sceptical about what they plan to do with my userid.  </p>
<p>There is a common technique that many people use where they create a site-specific version of their email address (I believed it is often called &#8220;plussed email addressing&#8221;).  For example, let&#8217;s say that my actual address is edwardaux@mydomain.com and I wanted to signup to <a href="http://www.flickr.com">flickr</a>, I could<br />
create an email address called edwardaux-flickr@mydomain.com and use that (and tell my mail server to forward all email to that address to my real edwardaux@mydomain.com address).  The nice thing about this is that if flickr is naughty (not that I am suggesting they are) and sells/gives my email address to spammers, I can immediately determine that by looking at who the email was addressed to.</p>
<p>The problem with this approach is that I have to go into my mail server ahead of time and manually create each site-specific email address.  That is a bit of a hassle, and I am sure that I can get away with a simpler approach.<br />
<span id="more-10"></span><br />
So, given that I am using a combination of <a href="http://www.qmail.org">qmail</a> and <a href="http://www.inter7.com/vpopmail">vpopmal</a> to manage my mail server, how might I configure them to do what I want?</p>
<p>Looking at the qmail documentation, I see that the suggested mechanism is to manipulate a file called <code>/home/edwardaux/.qmail-xxx</code>, where <code>xxx</code> is the site-specific alias I want.  For example, <code>.qmail-flickr</code> would match any email coming to edwardaux-flickr@mydomain.com.  However, this still means that I have to manually create explicit files for every site I want to sign up to.  There is another special variant of this file called <code>.qmail-default</code>, which is the catch-all for all addresses that don&#8217;t have a specific <code>.qmail-xxx</code> that matches the incoming mail.  It looks like this is the guy I want because it should mean I don&#8217;t have to keep creating explicit files.</p>
<p>However, as I am using vpopmail to manage multiple domains, the default .qmail-default file location will not work because qmail doesn&#8217;t deliver the mail directly to my /home/edwardaux mailbox.  Instead, it hands all mail to vpopmail who then decides which virtual domain and virtual user to deliver it to.  So, looking at the vpopmail configuration files, I found one called <code>/home/vpopmail/domains/mydomain.com/.qmail-default</code>.  This is the catch-all configuration file for all mail delivered to the mydomain.com virtual domain.</p>
<p>vpopmail supports a subtle variation on this file that incorporates the user&#8217;s email address.  I created a file called: <b>/home/vpopmail/domains/mydomain.com/.qmail-edwardaux-default</b> and added the following:</p>
<p><b>| /home/vpopmail/bin/vdelivermail &#8221; edwardaux@mydomain.com</b></p>
<p>Note that the above line contains two single quotes (&#8216;), not a double-quote (&#8220;)</p>
<p>What this does is forward all mail that is addressed to edwardaux-anything@mydomain.com to edwardaux@mydomain.com.  A quick restart of qmail (<code>/var/qmail/bin/qmailctl restart</code>) and I was set to go.  So, now I can dynamically make up as many combinations of edwardaux-xxx@mydomain.com as I like without having to create individual .qmail-xxx files ahead of time.</p>
<p>One thing that you need to be conscious of, though, is that now if spammers send mail to edwardaux-aaa@mydomain.com, edwardaux-bbb@mydomain.com, edwardaux-ccc@mydomain.com, then all that will come through to my inbox, whereas it used to just get thrown away.  I think I can live with that, though.</p>
<p>Enjoy!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/edwardaux.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/edwardaux.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/edwardaux.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/edwardaux.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/edwardaux.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/edwardaux.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/edwardaux.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/edwardaux.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/edwardaux.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/edwardaux.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/edwardaux.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/edwardaux.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=edwardaux.wordpress.com&blog=398350&post=10&subd=edwardaux&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://edwardaux.wordpress.com/2007/01/13/tracking-spam-origination-using-qmail-and-vpopmail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78ca0337f048eead2861b667cc627041?s=96&#38;d=identicon" medium="image">
			<media:title type="html">edwardaux</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring Tomcat5 and Apache2 to run with multiple instances</title>
		<link>http://edwardaux.wordpress.com/2006/09/20/3/</link>
		<comments>http://edwardaux.wordpress.com/2006/09/20/3/#comments</comments>
		<pubDate>Wed, 20 Sep 2006 23:39:19 +0000</pubDate>
		<dc:creator>edwardaux</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://edwardaux.wordpress.com/2006/09/20/3/</guid>
		<description><![CDATA[This describes the process for configuring Tomcat 5 on Ubuntu (or Debian) so that you can have multiple instances of Tomcat running.  Typically, this would be useful when you have several domains (and/or applications)  hosted on the one server and want to keep them running independantly of one another.
The general steps are based [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=edwardaux.wordpress.com&blog=398350&post=3&subd=edwardaux&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This describes the process for configuring Tomcat 5 on Ubuntu (or Debian) so that you can have multiple instances of Tomcat running.  Typically, this would be useful when you have several domains (and/or applications)  hosted on the one server and want to keep them running independantly of one another.</p>
<p>The general steps are based loosely on <a href="http://www.linuxjournal.com/article/8561">an article in LinuxJournal</a>, however, I have added afew more explanations, corrected a couple of little inaccuracies and added new content to describe the Apache2 mechanism for loading modules and sites.</p>
<p><span id="more-3"></span></p>
<h2>Pre-installed software</h2>
<p>This guide assumes that you have already installed the following applications via apt-get:</p>
<ul>
<li>j2sdk1.4</li>
<li>tomcat5</li>
<li>apache2</li>
<li>apache2-threaded-dev</li>
<li>build-essentials</li>
<li>a2enmod</li>
</ul>
<h2>Tomcat configuration</h2>
<p>Two important environment variables for Tomcat are <tt>CATALINA_HOME</tt> and <tt>CATALINA_BASE</tt>.  The first one is where the Tomcat files are  actually installed (on Ubuntu Dapper Drake, using apt-get, this is <tt>/usr/share/tomcat5</tt>).  The second one is where each running instance of Tomcat looks to find the configuration files and web applications. In the default installation, these variables are set to the same value. What we are going to do is create a directory for each of our webapps, and then start multiple instances of Tomcat with a different <tt>CATALINA_BASE</tt> for each one.</p>
<p>My suggested location (although I am open to feedback) is to create a new directory called <tt>/usr/share/tomcat5/instances</tt> that contains your applications.  Looking at that containing directory, though, you see something like:<br />
<tt></p>
<pre>
4 drwxr-xr-x   2 root root 4096 2006-08-15 08:02 bin
4 drwxr-xr-x   5 root root 4096 2006-03-19 16:27 common
0 lrwxrwxrwx   1 root root   21 2006-03-23 22:17 conf -&gt; /var/lib/tomcat5/conf
4 drwxr-xr-x   2 root root 4096 2006-03-23 22:17 .debian
0 lrwxrwxrwx   1 root root   14 2006-03-23 22:17 doc -&gt; ../doc/tomcat5
0 lrwxrwxrwx   1 root root   21 2006-03-23 22:17 logs -&gt; /var/lib/tomcat5/logs
4 drwxr-xr-x   5 root root 4096 2006-03-23 22:17 server
0 lrwxrwxrwx   1 root root   23 2006-03-23 22:17 shared -&gt; /var/lib/tomcat5/shared
0 lrwxrwxrwx   1 root root   21 2006-03-23 22:17 temp -&gt; /var/lib/tomcat5/temp
0 lrwxrwxrwx   1 root root   24 2006-03-23 22:17 webapps -&gt; /var/lib/tomcat5/webapps
0 lrwxrwxrwx   1 root root   21 2006-03-23 22:17 work -&gt; /var/lib/tomcat5/work
</pre>
<p></tt><br />
You will notice that all the actual files are stored in <tt>/var/lib/tomcat5</tt> with symbolic links across to them.  To keep with this  tradition, I used the following commands (all as root):<br />
<tt></p>
<pre>
mkdir /var/lib/tomcat5/instances
ln -s /var/lib/tomcat5/instances /usr/share/tomcat5/instances
cd /usr/share/tomcat5/instances
</pre>
<p></tt><br />
So, now the base directories have been created, you need to do the initial setup for the Tomcat servers.  Run the following commands for your webapp (where <tt>myapp</tt> is the name of your webapp):<br />
<tt></p>
<pre>
mkdir -p myapp/conf myapp/logs myapp/webapps
cp ../conf/server.xml myapp/conf
cp ../conf/web.xml myapp/conf
</pre>
<p></tt><br />
Copy your application WAR file into the <tt>myapp/webapps</tt> directory, and we should be ready to go.</p>
<h2>Starting your new instance</h2>
<p>We can&#8217;t use the original <tt>/usr/share/tomcat5/bin/startup.sh</tt> to start each instance because it uses the default <tt>CATALINA_BASE</tt>, so what we  do is create a new script file that can start and stop each instance, but pointing to a different <tt>CATALINA_BASE</tt>. Create a file called <tt>/usr/share/tomcat5/instances/myapp/myapp.sh</tt> that contains the following:<br />
<tt></p>
<pre>
#!/bin/sh

RETVAL=$?
export JAVA_HOME=/usr/lib/j2se/1.4
export CATALINA_BASE="/usr/share/tomcat5/instances/myapp"
export CATALINA_HOME="/usr/share/tomcat5"
export CATALINA_PID=$CATALINA_BASE/logs/catalina.pid

case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            exec $CATALINA_HOME/bin/startup.sh
        fi
        ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            exec $CATALINA_HOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac
exit $RETVAL
</pre>
<p></tt><br />
Make sure the original Tomcat instance is stopped (by running <tt>sudo /etc/init.d/tomcat5 stop</tt>) and start your new instance by typing:<br />
<tt></p>
<pre>
sudo chmod 755 ./myapp.sh
sudo ./myapp.sh start
</pre>
<p></tt><br />
Now test that Tomcat started up by pointing your browser to port 8180 of your machine with a valid myapp URL.</p>
<p>At this point, all we have really done is to make Tomcat start your application from a different directory.  Useful, but not yet where we want to be. We realy want to be able to point the browser to port 80, instead of the non-typical port of 8180.  So, we need to  configure Apache to hand off to the new running instance using mod_jk.</p>
<h2>mod_jk</h2>
<p>mod_jk is the means by which Apache hands off incoming HTTP requests to the Tomcat instances.  There are two flavours: mod_jk and mod_jk2.   Despite what you would think, mod_jk is the more actively developed version and is actually much simpler to install and configure.</p>
<p>In the original version of Apache, you used to have to modify the <tt>httpd.conf</tt> file, however, with Apache2 things have changed a little.  You can still edit <tt>/etc/apache2/httpd.conf</tt> if you like, but that isn&#8217;t the recommended way to configure Apache2.  Instead, you will be creating configuration files in the following two directories:</p>
<ul>
<li><tt>/etc/apache2/mods-available</tt></li>
<li><tt>/etc/apache2/sites-available</tt></li>
</ul>
<p>Before you do that, however, you need to install mod_jk.  Download the <a href="http://www.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.14/jakarta-tomcat-connectors-1.2.14.1-src.tar.gz">mod_jk source code</a>, and run the following commands:<br />
<tt></p>
<pre>
tar -xzvf jakarta-tomcat-connectors-1.2.14.1-src.tar.gz
cd jakarta-tomcat-connectors-1.2.14.1/jk/native
./configure --with-apxs=/usr/sbin/apxs2
make
sudo make install
</pre>
<p></tt><br />
The last command should install a file called <tt>mod_jk.so</tt> in <tt>/usr/lib/apache2/modules</tt>.  You might want to just quickly check that it is  there. </p>
<p>Now, you need to create a file called <tt>/etc/apache2/mods-available/jk.load</tt> that contains:<br />
<tt></p>
<pre>
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
</pre>
<p></tt></p>
<p>Next, create a file called <tt>/etc/apache2/mods-available/jk.conf</tt> that contains:<br />
<tt></p>
<pre>
&lt;IfModule mod_jk.c&gt;
  JkWorkersFile       "/etc/apache2/workers.properties"
  JkLogFile           "/var/log/apache2/mod_jk.log"
  JkLogLevel          info
  JkLogStampFormat    "[%a %b %d %H:%M:%S %Y] "
  JkOptions           +ForwardKeySize +ForwardURICompat -ForwardDirectories
  JkRequestLogFormat  "%w %V %T"
&lt;/IfModule&gt;
</pre>
<p></tt></p>
<p>Now, from the command prompt, type the following commands to enable it and become effective.  The <tt>a2enmod</tt> command enables a specific module by creating a symbolic link in <tt>/etc/apache2/mods-enabled</tt> that points to the equivalent file in <tt>/etc/apache2/mods-available</tt> directory.<br />
<tt></p>
<pre>
sudo a2enmod jk
sudo /etc/init.d/apache2 force-reload
</pre>
<p></tt></p>
<p>Nice work.  Now you have enabled mod_jk.  Now we have to configure a virtual host in Apache to point to our Tomcat instance.  You do this by creating a file called <tt>/etc/apache2/sites-available/yourdomain.com</tt> and adding the following content:<br />
<tt></p>
<pre>
&lt;VirtualHost yourdomain:80&gt;
        ServerAdmin admin@yourdomain.com
        ServerName  yourdomain.com
        ServerAlias www.yourdomain.com

        JkMount /* myapp
&lt;/VirtualHost&gt;
</pre>
<p></tt></p>
<p>This defines a virtual domain that has a Tomcat application called <tt>myapp</tt>. In fact, the <tt>myapp</tt> identifier is not actually the application name,  but actually references an entry in the <tt>workers.properties</tt> file (see below).  However, while not strictly necessary, if you keep this naming convention it makes it nice and easy to read the configurations when your mod_jk identifiers are the same as your webapp names. The <tt>JkMount /* myapp</tt> directive instructs Apache to send all urls to Tomcat (via mod_jk).  You  can, if you choose, a different pattern that more accurately reflects which requests you want Tomcat to handle (for example, <tt>JkMount /*.do myapp</tt>).</p>
<p>You need to make this new site available for use, so type the following command:<br />
<tt></p>
<pre>
sudo a2ensite yourdomain.com
sudo /etc/init.d/apache2 force-reload
</pre>
<p></tt></p>
<p>And lastly, we need to tell mod_jk what port Tomcat will be listening on by creating the configuration file that we referenced in  <tt>/etc/apache2/mods-available/jk.conf</tt>.  So, create a new file called <tt>/etc/apache2/workers.properties</tt> that contains:<br />
<tt></p>
<pre>
worker.list=myapp

# Set properties for myapp
worker.myapp.type=ajp13
worker.myapp.host=localhost
worker.myapp.port=8009
</pre>
<p></tt></p>
<p>The <tt>worker.list</tt> directive says which of the configurations is available for use.  For now, only <tt>myapp</tt> is available because we have only got one application.  This tutorial has Tomcat and Apache on the same machine, so we use <tt>localhost</tt> as the host.  The port that mod_jk will send connections to is 8009, which is the default Tomcat AJP13 listening port. When we add second, and subsequent, applications we will use different port numbers.</p>
<p>Stop and restart Apache by running the following command:<br />
<tt></p>
<pre>
/etc/init.d/apache2 restart
</pre>
<p></tt></p>
<p>Now, point your browser to your machine, but on port 80 this time.  If all has gone well, you should seamlessly get passed through  Apache into Tomcat via AJP.</p>
<p>The last thing to do is make Tomcat only accept incoming connections via the AJP connector, instead of allowing connections  directly to port 8180 (the HTTP connector).  This can be done by editing the <tt>myapp/conf/server.xml</tt> to comment out the HTTP connector.<br />
<tt></p>
<pre>
&lt;!-- Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
               port="8180" minProcessors="5" maxProcessors="75"
               enableLookups="true" acceptCount="10" debug="0"
               connectionTimeout="20000" useURIValidationHack="false" / --&gt;
</pre>
<p></tt></p>
<h2>Adding second and subsequent webapps</h2>
<p>Adding additional webapps is reasonably straightforward. One thing to decide before proceeding is what port numbers to use for your new webapp(s).  The default server.xml will have the shutdown port being 8005 and the AJP connector port being 8009.  Now, we already know that our first webapp (myapp, in this example) is using those ports, so we need to pick new port  numbers.  You can pick any port numbers you like, but the convention seems to be 8105/8109 for the second webapp, 8205/8209  for the third, and so on. The required steps are outline below:</p>
<ol>
<li>Run the following commands:<br />
<tt></p>
<pre>
mkdir -p app2/conf app2/logs app2/webapps
cp ../conf/server.xml app2/conf
cp ../conf/web.xml app2/conf
</pre>
<p></tt>
</li>
<li>Edit the <tt>app2/conf/server.xml</tt>, changing these items:
<ul>
<li>Change the port attribute of the <tt>&lt;Server&gt;</tt> tag from 8005 to 8105.</li>
<li>Change the port attribute of the AJP <tt>&lt;Connector&gt;</tt> tag from 8009 to 8109.</li>
<li>Optionally, comment out the HTTP <tt>&lt;Connector&gt;</tt> tag.  If you don&#8217;t comment it out (and you didn&#8217;t comment it out in <tt>myapp/conf/server.xml</tt>) you will need to change the value from 8180 to 8181 (or some other port) so that the HTTP connectors of your two webapps aren&#8217;t listening on the same port.</li>
</ul>
</li>
<li>Edit the <tt>/etc/apache2/workers.properties</tt> to add new lines that look like:<br />
<tt></p>
<pre>
worker.list=myapp,app2

# Set properties for myapp
worker.myapp.type=ajp13
worker.myapp.host=localhost
worker.myapp.port=8009

# Set properties for app2
worker.app2.type=ajp13
worker.app2.host=localhost
worker.app2.port=8109
</pre>
<p></tt>
</li>
<li>Create a file called <tt>/etc/apache2/sites-available/anotherdomain.com</tt> and adding the following content:<br />
<tt></p>
<pre>
&lt;VirtualHost anotherdomain:80&gt;
        ServerAdmin admin@anotherdomain.com
        ServerName  anotherdomain.com
        ServerAlias www.anotherdomain.com

        JkMount /* app2
&lt;/VirtualHost&gt;
</pre>
<p></tt>
  </li>
<li>Enable your new site by running the following commands:<br />
<tt></p>
<pre>
sudo a2ensite anotherdomain.com
sudo /etc/init.d/apache force-reload
</pre>
<p></tt>
	</li>
<li>Copy the <tt>myapp/myapp.sh</tt> script as <tt>app2/app2.sh</tt> directory, and modify the line with <tt>CATALINA_BASE</tt> to point to the <tt>app2</tt> directory instead of the <tt>myapp</tt> directory.</li>
<li>Copy your application WAR file into the <tt>app2/webapps</tt> directory</li>
<li>Restart Apache by running <tt>/etc/init.d/apache2 restart</tt></li>
<li>Start your application by running <tt>app2.sh start</tt></li>
</ol>
<h2>Starting automatically</h2>
<p>Now, having installed your webapp successfully, you may want to get it to start automatically upon a system restart. The conventional way to do this is to run the following commands:<br />
<tt></p>
<pre>
sudo ln -s /usr/share/tomcat5/instances/myapp/myapp.sh /etc/init.d/myapp.sh
sudo update-rc.d /etc/init.d/myapp.sh defaults 70
</pre>
<p></tt><br />
Repeat these commands for whichever Tomcat servers you want automatically restarted.</p>
<h2>Feedback</h2>
<p>If you spot any typos or mistakes, please let me know and I will correct ASAP.  Thanks a lot.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/edwardaux.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/edwardaux.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/edwardaux.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/edwardaux.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/edwardaux.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/edwardaux.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/edwardaux.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/edwardaux.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/edwardaux.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/edwardaux.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/edwardaux.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/edwardaux.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=edwardaux.wordpress.com&blog=398350&post=3&subd=edwardaux&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://edwardaux.wordpress.com/2006/09/20/3/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/78ca0337f048eead2861b667cc627041?s=96&#38;d=identicon" medium="image">
			<media:title type="html">edwardaux</media:title>
		</media:content>
	</item>
	</channel>
</rss>