Tomcat installation

Package installation

First, install the Tomcat server packages. Jiglu will work with Tomcat versions 8.5 and 9.0.

On OpenSuse use:

zypper install tomcat

On Amazon Linux instead use:

amazon-linux-extras install tomcat9

Configuration

Configuration files for Tomcat are normally located in /etc/tomcat or /etc/tomcat8. Changes will need to be made to the following files:

tomcat.conf / tomcat8.conf

Changes need to be made to made to enable headless mode so image processing can be used without a display, to allow encoded slashes in URLs, to disable message compression with web sockets and to set a reasonable memory size. Normally this will be through adding or changing the CATALINA_OPTS property:

CATALINA_OPTS="-Djava.awt.headless=true -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true -Dorg.apache.tomcat.websocket.DISABLE_BUILTIN_EXTENSIONS=true -Xmx512M"

web.xml

Development mode should be turned off for the jsp servlet:

<init-param>
<param-name>development</param-name>
<param-value>false</param-value>
</init-param>

server.xml

A host definition will need to be added for the server:

<Host name="jiglu.example.com"
appBase="webapps"
autoDeploy="true"
unpackWARs="true">

<Valve className="org.apache.catalina.valves.RemoteIpValve" />
<Valve className="org.apache.catalina.valves.ErrorReportValve"
showReport="false"
showServerInfo="false" />
</Host>

The RemoteIpValve is required to pass through details of the remote IP address for logging purposes. The ErrorReportValve will prevent details of the server internals being shown to users for malformed requests.

In the connector definition you will want to increase the maximum size for a discarded upload so if users try and upload too large a file they will get an error message rather than having the connection reset by Tomcat, though enforcing a maximum is still a good idea. You may also want to allow file compression for scripts and stylesheets:

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxSwallowSize="134217728"
compressableMimeType="text/javascript,text/css"
compression="2048"
redirectPort="8443" />

Deployment descriptor

In the Catalina directory, add a deployment descriptor by creating a directory with the same name as the host name above and inside it adding a ROOT.xml file:

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/opt/jiglu/webapp" path="">
<Parameter
name="com.jiglu.rmi.host"
value="localhost"
override="false" />
<Parameter
name="com.jiglu.rmi.port"
value="17001"
override="false" />
</Context>

The host value will need to be that of the machine where the Jiglu server can be found and the RMI port value that of the port number, as found in the Jiglu bootstrap.properties file.

Automatic starting

To enable Tomcat to start when the server is booted use:

systemctl enable tomcat

Tomcat will be started later in the installation process.

Written by Stephen Hebditch. Published on .
13.0.0
Installing and configuring the Tomcat web container.