If you are running Ubuntu and want to use the Tomcat Servlet
Container, you shoshould not use the version from the repositories as it
Just doesn't work correctly. Instead you'll need to use the manual
Installation process that I'm outlining here.
Before you install Tomcat you'll want to make sure that you 've ve
Installed Java. I wowould assume if you are trying to install Tomcat
You 've already installed Java, But if you Aren't sure you can check
With the dpkg command like so:
Dpkg-get-selections | grep sun-Java
This shoshould give you this output if you already installed Java:
Install sun-java6-bin
Install sun-java6-jdk
Install sun-java6-jre
If that command has no results, you'll want to install the latest version with this command:
Sudo apt-Get install sun-java6-jdk
Installation
Now we'll download and extract Tomcat from the Apache site. You should check to make sure there's not another version and adjust accordingly.
Wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.tar.gz
Tar xvzf apache-tomcat-6.0.14.tar.gz
The best thing to do is move the Tomcat folder to a permanent
Location. I chose/usr/local/tomcat, but you can move it somewhere
Else if you wanted.
Sudo mv apache-Tomcat-6.0.14/usr/local/tomcat
Tomcat requires setting the java_home variable. The best way to do
This is to set it in your. bashrc file. You cocould also edit your
Startup. Sh file if you so chose.
The better method is editing your. bashrc file and adding the bolded
Line there. You'll have to logout of the shell for the change to take
Effect.
VI ~ /. Bashrc
Add the following line:
Export java_home =/usr/lib/JVM/Java-6-sun
At this point you can start Tomcat by just executing the startup. Sh script in the tomcat/bin folder.
Automatic starting
To make Tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.
Sudo VI/etc/init. d/tomcat
Now paste in the following:
# Tomcat auto-start
#
# Description: auto-starts Tomcat
# Processname: Tomcat
# Pidfile:/var/run/tomcat. PID
Export java_home =/usr/lib/JVM/Java-6-sun
Case $1 in
Start)
SH/usr/local/tomcat/bin/startup. Sh
;;
Stop)
SH/usr/local/tomcat/bin/shutdown. Sh
;;
Restart)
SH/usr/local/tomcat/bin/shutdown. Sh
SH/usr/local/tomcat/bin/startup. Sh
;;
Esac
Exit 0
You'll need to make the script executable by running the CHMOD command:
Sudo chmod 755/etc/init. d/tomcat
The last step is actually linking this script to the startup folders
With a symbolic link. Execute these two commands and we shoshould be on
Our way.
Sudo ln-S/etc/init. d/tomcat/etc/rc1.d/k99tomcat
Sudo ln-S/etc/init. d/tomcat/etc/rc2.d/s99tomcat
Tomcat shoshould now be fully installed and operational. Enjoy!
The geek is the founder of how-to geek and a geek enthusiast. When he's
Not coming up with great how-to articles, he's probably writing at his personal blog.
Category:
Linux