Using Tomcat6 on Ubuntu Server 9.10

By Benjy | Posted, August 21st, 2009 and modified on August 21st, 2010.
This relates to our built to order Hospital Management System (HMS) commonly known as HIS (Hospital Information System). I hope that it might make some things clearer for those who are in the process of implementing software on similar platforms.

tomcatThis relates to our built to order Hospital Management System (HMS) commonly known as HIS (Hospital Information System). I hope that it might make some things clearer for those who are in the process of implementing software on similar platforms.To put things into perspective, I am listing the components of our HMS system:

It runs on Ubuntu Server, uses MySQL , Apache and Tomcat.  After the base install, I selected LAMP, Open SSH Server and Tomcat Java Server.  (A good server install guide can be found at http://www.ubuntugeek.com/step-by-step-ubuntu-9-10-karmic-lamp-server-setup.html ) I chose Ubuntu 9.10 over its LTS predecessor with its longer support cycle (read as updates) on account of Tomcat being integrated along with the Ubuntu  starting version 9.04. This  seems to be the way Ubuntu will take in in future releases…  so better flow with the tide than run into trouble at the end of the LTS support for Hardy Heron (8.04)

According to my personal preferences, after I installed Ubuntu, I disconnected all peripherals and set it up as a headless box.  I usually SSH from my laptop to the Linux box for the rest of the configuration.

As usual do a sudo apt-get update and then a sudo apt-get upgrade to get your system up to date.

There seem to be three different ways to run Tomcat6.

  1. The old way, where you download the zipped file from their server, extract it and run it as a stand alone application.  All the required folders, conf, logs, bin etc. reside within that folder. You’d also need to set bin/startup.sh to run automatically on boot and call the bin/shutdown.sh for a proper shutdown (or execute the scripts manually - ./startup.sh and ./shutdown.sh)
  2. The second method is standard with Ubuntu Karmic and is installed using tasksel either after the base install or by invoking tasksel after the server is up and running.
  3. The third option is outlined below, probably for developers who need to run multiple instances of Tomcat on different ports for testing different webapps.

The methods 2 & 3 are more secure and you get the regular centralised update and security fixes. Method one however is like running a program from the My Documents folder in Windows. Any malicious program/user can manipulate it, gain access to the logs or delete it. The version of Tomcat also stays at the same revision and all fixes/updates have to be done manually!

I  used the steps outlined in the Ubuntu Wiki. (Before this I had  uploaded the .war file to the /var/lib/tomcat6/webapps folder and it had auto deployed, even though it wasn’t accessible from the browser). Ubuntu 9.04 onwards, it is possible to run different instances of Tomcat simultaneously. This was probably imeplemented with the developer in mind who would be working on different projects. So leaving the experiments for later, I decided to run a private instance of tomcat and did the following:

sudo apt-get purge tomcat6

sudo apt-get install tomcat6-user

tomcat6-instance-create mytomcat6  (mytomcat6 can be called whatever you wish -it creates a folder in your home folder by the same name inside which you can find your webapps, bin and startup & shutdown scripts)

mytomcat6/bin/startup.sh

I then copied my .war file into ~/mytomcat6/webapps/ and it deployed immediately and the app started working. On a server you would need to set this script to run automatically on startup. In Webmin, you can do so from  System > Bootup and shutdown > Create a New Bootup & Shutdown action.

For MySQL since it defaults to be accessible only from the local host and denies root access from another machine, I used Webmin to create a new user and give the user full rights. I also modified the MySQL configuration through Webmin to listen on any host. Now I could use the MySQL administrator (and query browser) from any machine for configuring & modifying the database. Once you have everything working to your satisfaction, you can restore the original configuration of MySQL for security and start the webmin service on demand via SSH instead of leaving it always running.

I’m still not sure that this is the right way to do things. I did try a few times by putting the .war file in the /var/lib/tomcat6/webapps folder. It sure did deploy, but the app wouldn’t run even if deployed from the Tomcat manager! I suspect it has something to do with the programming by our vendor as I downloaded a WAR file from the net for testing and it worked very well.

Note:

The problem that I faced running tomcat from the /var/lib/tomcat6 folder was because of some other problem which is outlined in this post

For users running tomcat in a production environment, these are the folders they should be concerned with both in ubuntu 9.1 and 10.04 (Lucid)

Folder to deploy your webapplication: /var/lib/tomcat6/webapps/

Location of the log files                                  : /var/log/tomcat6/

Tomcat configuration                                     : /etc/tomcat6/

Tomcat startup script                                      : /etc/init.d/tomcat6 [This is where you can change Tomcats security settings]

http://simplysimple.info/wp-content/plugins/sociofluid/images/digg_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/reddit_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/delicious_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/blogmarks_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/newsvine_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/technorati_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/magnolia_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/google_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/myspace_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/facebook_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/mixx_48.png http://simplysimple.info/wp-content/plugins/sociofluid/images/twitter_48.png

Comment on this post

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is 14 + 6 ?
Please leave these two fields as-is:

Spam protection by WP Captcha-Free

+(reset)-
Follow me
© 2009 Simplysimple.info webmaster simplysimple.info