Configuring Tomcat in Ubuntu with Apache server running on it
Login with the root account. Check if java is already installed on the machine. If not, first install java on ubuntu.
Web get the apache-tomcat tar file from the below location
$ cd /tmp
$ wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
Untar the file
$ tar xvzf apache-tomcat-6.0.18.tar.gz
Move the tomcat file to a location of your choice
$ mv apache-tomcat-6.0.18 /usr/local/tomcat
Now, edit the profile setting to add JAVA_HOME setting
$ vi ~/.bashrc
Add the below line and save the file
export JAVA_HOME=/usr/lib/jvm/java-6-sun
Now restart tomcat
$ /usr/local/tomcat/./startup.sh
Another way to do this is to setup a shell script in /etc/init.d
$ vi /etc/init.d/tomcat
#Tomcat start, stop, restart
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
Save the file and given execute permission for the script. Check your path settings for JAVA_HOME and the tomcat file locations to ensure that the script executes as expected.
$ chmod 755 tomcat
Now you can start, stop, restart tomcat as
$ /etc/init.d/tomcat start
$ /etc/init.d/tomcat stop
$ /etc/init.d/tomcat restart
Test if Tomcat is running smoothly by going to
http://localhost:8080/
It should show the welcome screen from Apache Tomcat.
Note that Tomcat takes up the port 8080 for its applications by default. You can configure Tomcat to run as several instances as well.