InstallTomcat
From Scantegrity Wiki
This page documents the installation and configuration of Apache Tomcat 6.0.18 and Apache 2.2.8 on a stock Ubuntu LTS system in support of deploying the Scantegrity backend servlet code through a public-facing Apache2 web server.
- Setup ubuntu to use Sun java by default:
-
- apt-get install sun-java6-jdk
- update-java-alternatives -s java-6-sun
-
- Install the Apache2 mod_jk package from the Ubuntu repository:
-
- apt-get install libapache2-mod-jk
-
- Download and decompress latest apache-tomcat to /opt directory:
-
- cd /opt
- wget http://apache.seekmeup.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz
- tar xvfz apache-tomcat-6.0.18.tar.gz
- mv apache-tomcat-6.0.18 tomcat
- mkdir tomcat/webapps-disabled
- mv tomcat/webapps/* tomcat/webapps-disabled
- chown -Rf www-data:www-data /opt/tomcat
-
- Create a tomcat start script in /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
- export CATALINA_HOME=/opt/tomcat
- case $1 in
- start)
- su www-data -c $CATALINA_HOME/bin/startup.sh
- ;;
- stop)
- su www-data -c $CATALINA_HOME/bin/shutdown.sh
- ;;
- restart)
- su www-data -c $CATALINA_HOME/bin/shutdown.sh
- su www-data -c $CATALINA_HOME/bin/startup.sh
- ;;
- esac
- exit 0
-
- Edit the file /opt/tomcat/conf/server.xml. Find the section that looks like this:
-
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
- Change it to look like this:
-
- <!--
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
- -->
- This will disable the HTTP connector (so no direct access to Tomcat, all will be handled via mod_jk and Apache2).
-
- Create the file /opt/tomcat/conf/workers.properties with the following contents:
-
- # Configuration for Linux
- workers.tomcat_home=/opt/tomcat
- workers.java_home=/usr/lib/jvm/java-6-sun
- ps=/
- worker.list=ajp13
- # Definition for Ajp13 worker
- worker.ajp13.port=8009
- worker.ajp13.host=localhost
- worker.ajp13.type=ajp13
-
- Create the file /etc/apache2/conf.d/jk.conf with the following contents (add a JkMount entry for every tomcat context you would like to export):
-
- JkWorkersFile /opt/tomcat/conf/workers.properties
- JkLogFile /opt/tomcat/logs/mod_jk.log
- JkLogLevel info
- JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
- JkMount /docs/* ajp13
-
- Run the following commands to make tomcat start on boot:
-
- chmod +x /etc/init.d/tomcat
- ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
- ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
-
- Issue an "/etc/init.d/tomcat start" to start the service (or just reboot).
- Issue an "/etc/init.d/apache2 restart" to load the mod_jk configuration in apache. It takes about 30 seconds for the ajp13 connection to sync up and come alive.
