Tuesday, December 16, 2008

Install tomcat on Ubuntu 8.10

1. Check if java get installed:
dpkg --get-selections | grep sun-java

2. Install Java:
sudo apt-get install sun-java6-jdk

3. Get tomcat from apache site:
wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.
18.tar.gz
tar xvzf apache-tomcat-6.0.18.tar.gz

4. Move tomcat to the location:
sudo mv apache-tomcat-6.0.18 /usr/local/tomcat

5. Add following line into .bashrc file:
export JAVA_HOME=/usr/lib/jvm/java-6-sun

6. Create /etc/init.d/tomcat
# 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

7. Change mode to executable.
sudo chmod 755 /etc/init.d/tomcat

8. Create links
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

9. Start up tomcat:
/etc/init.d/tomcat start

10. Check the tomcat at http://127.0.0.1:8080 with FireFox, it compains the connection rest. The port 8080 has been used by Oracle, so tomcat has to use a different port. Modify "Connector port="8080" to "Connector port="8090" in /usr/local/tomcat/config/server.xml, then restart tomcat. Re-check tomcat at http://127.0.0.1:8090 again, it works.

11. To be able to check Status and Tocat Manager, the manager ID and password have to be setup. Add following lines in /usr/local/tomcat/config/tomcat-users.xml:
<user username="ABC" password="PASSWORD" roles="tomcat,manager,admin">

No comments: