3 :Reference: http://tldp.org/HOWTO/MMBase-Inst-HOWTO/index.html
4 :Copyright: Copyright (c) 2003 - 2006 Adrian Offerman
5 :License: Creative Commons Attribution-ShareAlike copyright license
7 Download a binary distribution of Tomcat from the Apache Jakarta website:
9 http://jakarta.apache.org/tomcat/
11 If you don't want to run the Tomcat daemon as root, create a new user/group
12 tomcat (first make sure that the UID and GID you use are still available by
13 checking the files /etc/passwd and /etc/group):
15 $ groupadd -g 220 tomcat
16 $ useradd -u 220 -g tomcat -c "Tomcat" \
17 -r -d /usr/local/tomcat \
18 -s "/sbin/nologin" tomcat
20 WARNING: You really should not use the root account to run the Tomcat daemon;
21 (using Tomcat version 4.1.27) we found out that this allows the MMBase admin
22 user to write backup dumps of his sites anywhere on the system. (TODO: better
25 Extract the Tomcat distribution in a new directory:
28 $ tar -zxvf .../jakarta-tomcat-xxx.tar.gz
30 NOTE: Version 4.1.27 came with a hot-fix:
32 $ cd /usr/local/jakarta-tomcat-xxx/
33 $ tar -zxvf .../xxx-hotfix-xxx.tar.gz
35 Change the ownership of the Tomcat directory and make it available as
38 $ chown -R tomcat:tomcat /usr/local/jakarta-tomcat-xxx
39 $ ln -s /usr/local/jakarta-tomcat-xxx /usr/local/tomcat
41 Open up the firewall for web access to the Tomcat server by adding to the file
42 /etc/sysconfig/iptables:
44 -A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 8080 --syn -j ACCEPT
46 You need to reboot your system to make this rule effective or restart the
49 $ service iptables restart
51 TIP: Since (for some odd reason) some network managers allow outgoing web
52 connections only to TCP port 80, there might be people around that cannot
53 access your Tomcat (and MMBase) server through port 8080. Elsewhere (at
54 http://tldp.org/HOWTO/MMBase-Inst-HOWTO/jk2.html), we will explain how to
55 install a JK 2 mapping or a reverse proxy in Apache, so Tomcat and MMBase can
56 be accessed through the Apache web server at port 80. Apart from the port
57 issue, this has the advantage that you can use Apache to manage you SSL
58 connections and use your existing Apache logs and statistics facilities for
59 Tomcat and MMBase as well.
61 If you decide to use Apache as a front-end to your Tomcat and MMBase server,
62 there's no need to open up port 8080 in your firewall.
64 To run Tomcat, set the $CATALINA_HOME environment variable:
66 $ export CATALINA_HOME=/usr/local/tomcat
70 $ /usr/local/tomcat/bin/startup.sh
72 Now you can access Tomcat's home page through (replace <hostname> with your
75 $ $BROWSER http://<hostname>:8080/
77 which should give you the Tomcat welcome screen.
81 $ /usr/local/tomcat/bin/shutdown.sh
83 Since we want to automate the starting up and shutting down of the Tomcat
84 server, we create a file /etc/rc.d/init.d/tomcat to do this for us:
88 # Startup script for the Jakarta Tomcat Java Servlets and JSP server
91 # description: Jakarta Tomcat Java Servlets and JSP server
93 # pidfile: /var/run/tomcat.pid
96 # Source function library.
97 . /etc/rc.d/init.d/functions
99 # Source networking configuration.
100 . /etc/sysconfig/network
102 # Check that networking is up.
103 [ ${NETWORKING} = "no" ] && exit 0
105 # Set Tomcat environment.
106 export JAVA_HOME=/usr/local/j2sdk
107 export CLASSPATH=.:/usr/local/j2sdk/lib/tools.jar:/usr/local/j2re/lib/rt.jar
108 export CATALINA_HOME=/usr/local/tomcat
109 export CATALINA_OPTS="-server -Xms64m -Xmx512m -Dbuild.compiler.emacs=true"
110 export PATH=/usr/local/j2sdk/bin:/usr/local/j2re/bin:$PATH
112 [ -f /usr/local/tomcat/bin/startup.sh ] || exit 0
113 [ -f /usr/local/tomcat/bin/shutdown.sh ] || exit 0
115 export PATH=$PATH:/usr/bin:/usr/local/bin
117 # See how we were called.
121 echo -n "Starting Tomcat: "
122 /usr/local/tomcat/bin/startup.sh
125 [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
129 echo -n "Shutting down Tomcat: "
130 /usr/local/tomcat/bin/shutdown.sh
133 [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat
140 [ -e /var/lock/subsys/tomcat ] && $0 restart
146 echo "Usage: $0 {start|stop|restart|status}"
154 Set its ownership and access rights:
156 $ chown root:root /etc/rc.d/init.d/tomcat
157 $ chmod 755 /etc/rc.d/init.d/tomcat
159 And add this init script to chkconfig:
161 $ chkconfig --add tomcat
162 $ chkconfig tomcat on
164 TIP: To install two (or even more) versions of Tomcat server on the same
165 system, increase the port numbers of the second server (e.g. by 10), by
166 editing the configuration file /usr/local/tomcat55/conf/server.xml:
168 <Server port="8015" shutdown="SHUTDOWN">
170 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
171 <Connector port="8090"
172 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
173 enableLookups="false" redirectPort="8453" acceptCount="100"
174 connectionTimeout="20000" disableUploadTimeout="true" />
176 <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
178 <Connector port="8453"
179 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
180 enableLookups="false" disableUploadTimeout="true"
181 acceptCount="100" scheme="https" secure="true"
182 clientAuth="false" sslProtocol="TLS" />
185 <!-- Define an AJP 1.3 Connector on port 8009 -->
186 <Connector port="8019"
187 enableLookups="false" redirectPort="8453" protocol="AJP/1.3" />
189 <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
190 <!-- See proxy documentation for more information about using this. -->
192 <Connector port="8082"
193 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
194 enableLookups="false" acceptCount="100" connectionTimeout="20000"
195 proxyPort="80" disableUploadTimeout="true" />
198 Complete this second Tomcat server installation as above for the first server,
199 using adjusted directory and file names.