Tomcat - Local Installation
Tomcat
home page
Tomcat
wiki
Tomcat is an Apache product similar to Apache Server except that it specializes in serving JSP files, which constitute the bulk of the e-Lab web apps. You can install Tomcat in its default directory for your OS and then symlink this default location to
~/quarkcat/sw/tomcat/
, or you can install it directly into
~/quarkcat/sw/tomcat/
. Most of us choose the former.
When the site ran on servers at Argonne (before Feb 2016), it used Tomcat6. When we moved to Notre Dame's CRC, we installed Tomcat7 on the VMs, and the site currently uses that version (Sept 2016). The notes below are for mostly Tomcat8, the most current major-number version as of Sept 2016, but you may see references to all three versions on this wiki.
You must have a Java Runtime Environment (JRE) installed to get basic functionality out of Tomcat. This is nearly always included in your OS. To deploy the website (even locally), however, you'll need the full Java Devepment Kit (JDK). If you want, you can worry about installing the JDK after you get Tomcat installed and working with Apache, but make sure you at least have a JRE before you start these instructions. The command
$ java -version
will tell you what you have. Obviously, there's no harm in installing the JDK before Tomcat, either. See the
Installing Java page for more.
Installation
OS X
The following notes were created while installing Tomcat 8.0.27 on OS X 10.11 (El Capitan), though they should be generalizable.
NB that OS X 10.7 and above do not have Java pre-installed. See the note above about installing Java before installing Tomcat.
Tomcat default installation path is
/usr/local/apache-tomcat-8.0.27/
(version number may vary).
Fedora 23
Tomcat is available in the main package repository; use
$ sudo dnf info tomcat
to learn more about what's available to you specifically. I found version 8.0.32 release 5.fc23 (Joel, June 2016).
$ sudo dnf install tomcat
The default set of installation directories is
Directory |
Contents |
Path |
/etc/tomcat/ |
configuration files |
$CATALINA_HOME/conf |
/usr/share/java/tomcat/ |
libraries |
$CATALINA_HOME/lib |
/usr/share/tomcat/bin/ |
executables |
$CATALINA_HOME/bin |
/var/log/tomcat/ |
logs |
$CATALINA_HOME/logs |
/var/cache/tomcat/temp/ |
temporary files |
$CATALINA_HOME/temp |
/var/cache/tomcat/work/ |
compiled servlets |
$CATALINA_HOME/work |
/var/lib/tomcat/ |
Tomcat home directory |
$CATALINA_HOME/ |
/var/lib/tomcat/webapps/ |
web applications |
$CATALINA_HOME/webapps |
Notes:
/var/log/tomcat/catalina.out
is the log
/usr/share/java/
itself has lots of tomcat-labeled files
/usr/share/tomcat/
has symlinks identical to those listed in the Path column, as if it were
$CATALINA_HOME
instead of
/var/lib/tomcat/
.
Ubuntu
This
AskUbuntu page has some great information on installing Tomcat on Ubuntu.
$ sudo apt-get install tomcat8
Configuration
We'll end up with Tomcat and Apache installed such that Apache "fronts" Tomcat, meaning that Apache's server process receives incoming requests first before passing them on to Tomcat.
We configure Tomcat for this arrangement through the main Tomcat config file
server.xml
, located at
OS |
location |
OS X El Capitan |
tomcat/conf/server.xml |
Ubuntu 14/16 |
/etc/tomcatX/server.xml |
Fedora 23 |
/etc/tomcat/server.xml |
Look for a block along the lines of
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
and make sure it's uncommented.
- AJP is Apache JServ Protocol, the protocol that governs Apache-Tomcat communication.
- TCP port 8009 is the (unofficial) standard port for AJP Connectors, and 8443 is the (unofficial) Tomcat SSL port.
-
port="8009"
means that this Connector will listen on port 8009.
-
redirectPort="8443"
means that incoming SSL requests on 8009 will be redirected to port 8443.
-
protocol="AJP/1.3"
means that we're using the AJP 1.3 protocol (there are other
protocols).
options
There are two additional options some developers have added to this
<Connector>
. Neither should affect the behavior of the site in any substantial way.
enableLookups="false"
improves performance a bit by not bothering to do a DNS lookup for the hostname of client connections.
URIEncoding="UTF-8"
specifies the encoding type for HTTP GET, POST, and Header data. The two main options are ISO-8859-1 (the default) and UTF-8. ISO-8859-1 was the most popular encoding about a decade ago, so you still see it all around the web, but UTF-8 is the dominant format at the moment (2016). Both encode ASCII exactly the same way, so there's little functional difference for us.
If you choose to use these, your AJP Connector in
server.xml
will look like
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
The order doesn't matter. This is all that needs to be done with Tomcat.
Enable Changes
After you've edited
server.xml
, you'll need to restart Tomcat (or start it, if it's not already running).
-- Main.JoelG - 2016-06-15