RimuHosting: Mighty Linux Servers.  Support Worth Raving About
Plans & Pricing
Server Recommendation Tool
Server Types
  VPS
  Semi-dedicated Server
  Dedicated Server
Server Locations
  Dallas
  London
  Australia
VPS Technology
Hardware
Data Centers
Linux Distributions
Applications
Maintenance Notices
Support Ticket
Control Panel
HOWTO Articles
Forums
VPS control panel
Billing details
Receipts
Contact details
DNS
Reverse DNS
Console-over-SSH
FTP backup space
Backup mail server
About
Staff
News
Customer Testimonials
Sales Inquiry
Link To Us
Terms and Conditions
Site Map

Order VPS Hosting
Order a VPS, Semi- dedicated or Dedicated server in Dallas, London or Australia.

Get Assistance
Ask our support team about your hosting requirements.


Host where the staff takes pride in making customers happy

My website is hosted by Rimu Hosting, based in New Zealand. Provide linux-based hosting, VPS, all sorts of applications (mail server, ftp, cvs, Java, database etc) at a very reasonable fee. Plus, I get 'root' access (via SSH ofcourse). Support is terrific (via Yahoo IM). Can't complain. Lots of packages/plans. Very developer-friendly. The folks there are very knowledgeable, and pretty hands-on. Recommend them wholeheartedly.

- Ragu on his blog http://www.shodaka.net/blojsom/blog/rhavaldar/tech/?permalink=744494B3DBE7388EFE48BC0E1ADA8892.txt (#249/269)
Home > Support > HOWTO List > JSP Hosting: Tomcat

Tomcat Servlet Engine

Tomcat is the 'reference' Servlet/JSP implementation.  It is probably the most widely used Servlet engine out there.  There are probably smaller, faster Servlet engines available, but if it won't run on Tomcat, it probably won't run period.

Using Tomcat

On some distros (e.g. RHEL4, and some pre-FC6 distros) RimuHosting pre-installs
the Tomcat Servlet engine.  If there is no /usr/local/tomcat directory on your server
and you want tomcat, then just run:


wget http://proj.ri.mu/installtomcat5.sh
# add --version 6 if you want tomcat 6 vs. tomcat 5
bash installtomcat5.sh

This installtomcat script should work on most Redhat-, Ubuntu- and Debian-based distros.

Almost all our distros have a JDK pre-installed.  If not you can install one using our installjava script (typically you can edit that file to select the JDK version you prefer (1.4, 1.5, 1.6, etc).

By default the Tomcat application does not run by default on server startup.  However, it is easy enough to do:

You can start/stop/restart the service with: /etc/init.d/tomcat start/stop/restart

Check tomcat is running:  http://yourserverip:8080

To run Tomcat without the :8080 port number, follow our mod_jk2/mod_proxy_ajp/iptables howto.

You can turn on the service so it runs at bootup: chkconfig --level 3 tomcat on

File locations of note:

At this point you may want to edit the configuration files to suit your setup.  After changing configuration settings, you may need to restart tomcat:

Tomcat File Permissions

Be careful of changing file permissions.  If a webapp or configuration file has the wrong permissions, then Tomcat will probably spit permissions-related errors at you.  Tomcat runs as the a regular Unix user (usually 'tomcat').  This is good, since it is not running as, say, root which introduces the potential for more security problems.

You can always re-set the file ownership by running chown -R tomcat:tomcat /usr/local/tomcat

Easy server.xml Edits with the Admin WebApp

From the admin webapp you can change and view your tomcat settings, add new Contexts, Loggers, and more.  Very handy if you are too shy to edit the server.xml file directly.

By default your Tomcat install is not setup with the admin webapp.  We do that for security reasons (i.e. so that someone cannot come along and use the default tomcat username and password to view your database details and change your Tomcat setup).

Setting up the Admin User

Edit /usr/local/tomcat/conf/tomcat-users.xml.

Add a line like:


 <user username="someusername" password="somepassword" roles="manager,admin"/>

Check that none of the default users have the manager or admin roles.

'Activate' the Admin and Manager Webapps

To activate the Admin webapp run this:


mkdir -p /usr/local/tomcat/server/webapps
# the original webapps were moved out of the way to 
# the webapps.removed directory on install for 
# safe-keeping.  Let us move them back.
mv /usr/local/tomcat/webapps.removed/server.webapps/* /usr/local/tomcat/server/webapps/
# put the webapp context in place
if [ -e /usr/local/tomcat/webapps.removed/manager.xml -a ! -e /usr/local/tomcat/conf/Catalina/localhost/manager.xml ]; then
    mv /usr/local/tomcat/webapps.removed/manager.xml /usr/local/tomcat/conf/Catalina/localhost/manager.xml
fi
# reset file ownership permissions
chown -R tomcat:tomcat /usr/local/tomcat
# restart tomcat so it picks up the changes
/etc/init.d/tomcat restart

You can now browse to http://yourip:8080/admin/ and you will be prompted for the username/password you setup in tomcat-users.xml.

Resolving: "Connection Refused" Error on Tomcat Stop

Error like this?


Catalina.stop: java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
        at
java.net.PlainSocketImpl.socketConnect(Native Method)
        at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)

If you run:
ps axf | grep [j]ava.endorsed.dir

It should give you one or more lines like this when Tomcat is running:
22587 pts/0   S     0:04 /usr/local/jdk/bin/java -Djava.endorsed.dirs= -classp

If you do not see any lines like that, then Tomcat may have died already.  In that case, execute this command:
rm /var/lock/subsys/tomcat4

It will remove the lock and you can restart tomcat.