Wednesday, January 28, 2009

Tomcat 6 on CentOS 5.2

1. Download jdk-6u11-linux-i586-rpm.bin from http://java.sun.com/javase/downloads/index.jsp.

2. cd Desktop; . jdk-6u11-linux-i586-rpm.bin

3. As root, insert following lines in /etc/profile
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

4. . /etc/profile

5. mkdir /tmp; cd /tmp

6. wget http://ftp.sh.cvut.cz/MIRRORS/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

7. tar xvzf apache-tomcat-6.0.18.tar.gz

8. mv -f apache-tomcat-6.0.18 /usr/share/tomcat6

9. chown -R tomcat /usr/share/tomcat6

10. ln -s /usr/share/tomcat6 /usr/share/tomcat

11. useradd -d /usr/share/tomcat -s /sbin/nologin tomcat

12. Create /etc/init.d/tomcat as shown below:

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/java/default

case $1 in
start)
sh /usr/share/tomcat6/bin/startup.sh
;;
stop)
sh /usr/share/tomcat6/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat6/bin/shutdown.sh
sh /usr/share/tomcat6/bin/startup.sh
;;
esac
exit 0

13. chmod +x /etc/init.d/tomcat

14. chkconfig tomcat6 on

15. Add following into /usr/share/tomcat/conf/tomcat-users.xml:
<user username="tomcat" password="tomcat" roles="manager,admin">

16. Add $CATALINA_HOME to /etc/profile.
export CATALINA_HOME=/usr/share/tomcat

17. /etc/init.d/tomcat start

18. If the Apache Tomcat page can be found at http://localhost:8080, the installation is correct.

19. Done.

1 comment:

Artem said...

Thanks so much.

Some things I had to adjust:

In step 2:
cd Desktop; sh jdk-6u11-linux-i586-rpm.bin

(Had to use use sh)

In Step 10
ln -s /usr/share/tomcat6/ /usr/share/tomcat
(The missing / after tomcat6 gave me trouble.)