How to install Apache Tomcat on Ubuntu
I was trying to install Apache Tomcat on Ubuntu for my friend from repository but the version from the repositories simply didnt work . So I made it installed manually and here is the steps on how to do that .
Before you install Apache Tomcat, make sure you are having Java installed on your box .
sudo apt-get install sun-java6-jdk It will make the Java installed .
Once done , proceed with apache tomcat installation :
First of all, download and extract Tomcat from the apache site. You should make sure for latest version and adjust it accordingly in the following instruction .
wget http://mirror.olnevhost.net/pub/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
tar xvzf apache-tomcat-6.0.18.tar.gz
Now we will move the tomcat folder to a permanent location.Preferably /usr/local/tomcat, but you could move it somewhere else if you wanted to.
sudo mv apache-tomcat-6.0.18 /usr/local/tomcat
Now we will handle the most important part . Apache Tomcat requires the JAVA_HOME variable should be set up properly. The best way to do this is to set it in .bashrc file.
The better method is editing your .bashrc file and adding the following line there.
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.
But we will go for the automatic start option
To make tomcat automatically start when boot up , 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
Next step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should 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
All done and your Apache Tomcat should be running at FQDN:8080 or localhost:8080 . Open a browser and access it .
The final step is to set Apache Tomcat Manager login credentials should be added for your management .
Edit the following file
vi /usr/local/tomcat/conf/tomcat-users.xml
And Add the following and save .
< role rolename="manager"/>
< user username="PUT_ANY_USERNAME" password="PUT_ANY_PASSWORD" roles="manager"/>
Now restart apache tomcat and all should be set to go ……
This entry was posted on Monday, August 11th, 2008 at 12:49 am and is filed under gnu/linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


