Terry : Upgrade Tomcat for Confluence

Upgrade Tomcat For Confluence

Upgrade history: 6.0.18, 6.0.20, 6.0.36, 6.0.37, 6.0.39, 6.0.41.

To be able to use Tomcat 7, Confluence version needs to be updated ;-D

The process is similar to initial installation.

Install / Upgrade Confluence

Steps to Install/Upgrade

1. Download the latest version from http://tomcat.apache.org

2. Extract the tarball, for example /opt/tomcat, change ownership recursively to www-data user (the user which is used to run apache, nginx and tomcat)

chown www-data:www-data /opt/tomcat/ -R

3. Download MySQL Connector/J, place mysql-connector-java-<version>.jar in $CATALINA_HOME/lib

4. Edit $CATALINA_HOME/bin/catalina.sh, search for JAVA_OPTS block and increase initial heap size and run JVM in server mode -server -Xms256m -Xmx512m

if [ -z "$LOGGING_MANAGER" ]; then
  JAVA_OPTS="$JAVA_OPTS -server -Xms256m -Xmx512m -XX:MaxPermSize=256m -Dhttp.proxyHost=proxy.company.com -Dhttp.proxyPort=80 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"

5. Extract confluence tar ball to /opt/confluence, edit confluence-init.properties


6. Configure context and data source for Confluence

mkdir -pv /opt/tomcat/conf/Catalina/localhost
chown www-data:www-data /opt/tomcat/conf/Catalina/localhost/ -R

Create /opt/tomcat/conf/Catalina/localhost/confluence.xml

<Context path="/confluence" docBase="/opt/confluence/confluence" debug="0" reloadable="true">
<Resource name="jdbc/confluence" auth="Container" type="javax.sql.DataSource"
         validationQuery="Select 1" />

7. Configure Tomcat for front-end reverse proxy

Backup and edit $CATALINA_HOME/conf/server.xml

cp /opt/tomcat/conf/server.xml{,.bak} 

Find Connector port="8080" block and make it look like below, proxyName is the FQDN of the front-end reverse proxy (apache or nginx)

    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true"
               proxyName="tux.apac.lab" proxyPort="80"
               URIEncoding="UTF-8" />

9. Configure MySQL for READ-COMMITTED transaction-isolation and UTF-8 charsets

# Required by confluence 3.5 and above
transaction-isolation = READ-COMMITTED 


default-character-set = utf8
default-character-set = utf8
# default-character-set = utf8
collation-server = utf8_unicode_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8 

10. Use mysql or phpMyAdmin to create user, allow only local connection (loopback), run mysql_secure_installation to secure MySQL if necessary

11. Create schema, grant privilege to user

12. Run installer if it's a new installation, otherwise it's done!

Shell script to start and stop Tomcat

Bash script

# tomcat.sh
# Description: Start or stop tomcat for confluence 
# Short-Description: start or stop tomcat
source /opt/java.sh
echo `java -version`
case "$1" in
        echo "Starting tomcat..."
        su -c '/opt/tomcat-6.0.36/bin/./startup.sh' www-data
        echo "Done."
        echo "Stopping tomcat..."
        su -c '/opt/tomcat-6.0.36/bin/./shutdown.sh' www-data
        echo "Done."
        echo "Usage: tomcat.sh {start|stop}"
        exit 1

A better Tomcat startup script from Ansible examples - tomcat-initscript.sh

Start Tomcat during boot

  1. Write a tomcat startup script in /etc/init.d/tomcat
  2. Invoke update-rc.d to run Tomcat as service (sysv-rc-conf is an alternative)

    update-rc.d tomcat enable
    update-rc.d tomcat defaults

    Or manually create symbolic links to the startup script in corresponding /etc/rcX.d/ directory.

    RHEL, OEL or CentOS equivalent

    chkconfig --level 345 tomcat on

    systemd (Arch Linux, Fedora, openSUSE) way is different. Need to create a unit file for Tomcat and enable it.

NOTE: Keep the old version of Tomcat for a while until you make sure the new version works well with current Confluence version.


Configuring a MySQL Datasource in Apache Tomcat

Configure Web Proxy Support for Confluence