Monday, January 31, 2011

Installing Tomcat In Ubuntu

Quick how to guide for installing Tomcat in Ubuntu


1) make sure that you have the necessary Java SDK's installed. Use the following bash command:
dpkg --get-selections | grep sun-java

You should have the following output:
sun-java6-bin
sun-java6-jdk
sun-java6-jre

If you get no results back then run the following command in the terminal to acquire the needed Java SDK

user@pc:~$sudo apt-get install sun-java6-jdk

2) Now we're ready to download and install Tomcat available at Apache's site. Check for the latest version download from the site or use the following command. Note this command is version specific so you may need to to adjust some numbers if you need a different version.
user@pc:~$wget http://apache.hoxt.com/tomcat/tomcat-7/v7.0.6/bin/apache-tomcat-7.0.6.tar.gz 

Now we will unpack the compressed file using this command:

user@pc:~$tar -xvzf apache-tomcat-7.0.6.tar.gz

It's a good idea to move the Tomcat folder to a permanent location and so we'll do the following:

user@pc:~$sudo mv apache-tomcat-7.0.6 /usr/local/tomcat

3) In order for Tomcat to run properly we need to set the JAVA_HOME variable in the .bashrc file which is located at:

user@pc:~$~/.bashrc

We'll open up the bashrc file for editing using the following command:

user@pc:~$ sudo vi ~/.bashrc

and we now append the following line at the end of the file:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

4) Before we can run Tomcat we'll need to log out of the current Ubuntu session since the changes that we made to the .bashrc file have not yet taken effect. We log back in and can now finally run Tomcat by executing the startup.sh script located in the tomcat/bin folder using the following terminal command:

user@pc:~$/usr/local/tomcat/bin/startup.sh

*Note to stop Tomcat we use the following command in the terminal:

user@pc:~$/usr/local/tomcat/bin/shutdown.sh

No comments:

Post a Comment

Online Marketing