Now that we have the latest version of Java configured on your DV we need Apache Tomcat to provide a “pure Java” HTTP web server environment for Java code to run. Tomcat should not be confused with the Apache web server, which is a C implementation of an HTTP web server; these two web servers are not bundled together.

1. Download and extract tomcat 6.0 binary distribution. Get the URL of the tar.gz file from http://tomcat.apache.org/download-60.cgi. From your ssh console download using wget.

wget http://apache.deathculture.net/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.tar.gz

Now use the following commands to extract the files.
gunzip -d apache-tomcat-6.0.14.tar.gz
tar -xvf apache-tomcat-6.0.14.tar

2. Login as root and set the JAVA_HOME variable to point to your Java installation. From your ssh console run this line, but make sure to edit the path to your Java install.

export JAVA_HOME=/usr/java/jdk1.6.0_04

3. Start tomcat from bin folder. Login again to SSH using your non root user id. The start up script for tomcat is in [tomcatdir]/bin.

Change to the bin directory (cd bin) and then execute, ./startup.sh

Your all set, you should see the tomcat server running at www.yoursite.com:8080/

To shutdown you can navigate back to bin and execute ./shutdown.sh

I ran into a permission issue while trying to then upload a file via ftp to <catalina-home>/webapps/ROOT/

My temporary work around was to login as a regular user via SSH, then change to root via su root, then wget my jsp files from another location. That got old fast, Even though I changed permissions via FTP icould not upload to /ROOT Then after investigating it further I was able to chmod 777 ROOT via SSH as root user, and Voila!

I then uploaded the simple hello_world.jsp code written below to

<catalina-home>/webapps/ROOT/

and was able to ping it at http://www.mysite.com:8080/hello_world.jsp

<code><HTML>
<HEAD>
<META HTTP-EQUIV=”Content-Type” CONTENT=”text/html; charset=WINDOWS-1252″>
<TITLE>JSP - Hello World</TITLE>
</HEAD>
<BODY>
<P><% out.println(” Hello Java World”); %> !</P>
</BODY>
</HTML>


COMMENTS / 2 COMMENTS

Hey thanks a lot for both of these articles!

I ran into a couple of permissions issues where the server would not start or shutdown properly, but I got around this by fixing the permissions on my conf directory.

Again, Thank you so much for these guides!

John added these pithy words on Jul 24 09 at 11:40 am

Chris, some day you will be canonised for services to web amateurs. I’m on a MT (dv) and have followed your instructions for installing Java and Tomcat. I have even been able to get the ‘Hello Java World’ code to work from mysite:8080/hello_world.jsp.

I have, however, run into problems when trying to serve java script on my main site (the files for which are located in /var/www/vhosts/mysite/httpdocs). Even ‘Hello Java World’ fails to display properly (it returns !).

I downloaded Java and Tomcat to /root. Do you have any idea what might be up? Any assistance will be hugely appreciated.

Best,

Tom

Tom added these pithy words on Jul 29 09 at 3:20 am

SPEAK / ADD YOUR COMMENT
Comments are moderated.




Return to Top

Installing Tomcat on a MediaTemple (DV) dedicated server