TermWeb 4 install on Linux

1

Prerequisites

Before beginning installation get ready next things and settings:

  • MySQL 8.0 with created scheme and user with access to it (MySQL security group should allow inbound rules from new EC2 instance, default port 3306)

2

Launch new Linux server

  • TermWeb is Java web application and can work in the same environment as JDK (Windows x64, Linux x64 or Linux aarch64)

  • For data storage will be enough from 10 to 45GB depending on usage, verbosity of logs and your term base size.

  • Most term bases containing 100K-200K terms will work normally with 4GB-8GB of RAM

  • The more powerful CPU is better for huge imports/exports or constant small imports.
    But for daily usage will be enough about vCores with at least 2.5GHz

  • Further instructions provided for linux distributions using yum package manager, for different package manager check documentation of your package manager.

  • Update everything after successful login sudo yum update and after most cases sudo reboot.

3

Configure Linux instance

In most cases we don’t need swap file because application is almost dead when it’s reading data from it. Instead we suggest to increase memory of your instance. But if your company policy requires it you may use next steps:

1. Calculate the swap space size (see):
a) 2 GB of RAM or less = swap size 2x the amount of RAM but never less than 32 MB
b) More than 2 GB of RAM but less than 32 GB = swap size 4 GB + (RAM – 2 GB)
c) 32 GB of RAM or more = swap size 1x the amount of RAM

2. For most use cases of TermWeb having more than 1GB of swap file is not necessary
Use the dd command to create a swap file on the root file system. In the command, bs is the block size and count is the number of blocks. The size of the swap file is the block size option multiplied by the count option in the dd command. Adjust these values to determine the desired swap file size.

The block size you specify should be less than the available memory on the instance or you receive a "memory exhausted" error.
In this example dd command, the swap file is 2 GB (128 MB x 8): 
sudo dd if=/dev/zero of=/swapfile bs=128M count=8 oflag=append conv=notrunc

3. Update the read and write permissions for the swap file:
sudo chmod 600 /swapfile

4. Set up a Linux swap area:
sudo mkswap /swapfile

5. Make the swap file available for immediate use by adding the swap file to swap space:  
sudo swapon /swapfile

6. Verify that the procedure was successful:
sudo swapon -s

7. Enable the swap file at boot time by editing the /etc/fstab file.
sudo nano /etc/fstab
Add the following new line at the end of the file, save the file and exit:
/swapfile swap swap defaults 0 0

To disable swap file use next command: sudo swapoff /swapfile
Delete swap file if you want to decrease file system usage.

Most of the linux distributions comes with MariaDB files, which have same executables as MySQL. If you have plans to create DB backups on this linux server, then you need to remove MariaDB files and install MySQL client.

Remove MariaDB as replacement of MySQL

* Remove mariadb files:
sudo yum remove mariadb mariadb-libs
sudo yum-config-manager --disable mariadb

* Install mysql client:
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
sudo yum install mysql80-community-release-el7-3.noarch.rpm
rm mysql80*.rpm
sudo yum install mysql-community-client

4

Install JDK

Download and install latest build of Open JDK 8 or Oracle JDK 8. Higher versions of Java not supported right now.
You may choose any vendor for JDK: Adopt JDK, Amazon Corretto JDK, Oracle, etc.
As we know Oracle JDK 8 requires paid subscription per server installation.

  • sudo yum install java-1.8.0-amazon-corretto-devel

5

Install Tomcat 9.0

Download and install latest build of Tomcat 9.0

We don’t know any good and trusted repository containing fresh versions of Tomcat so we can’t give to you any short command.

If you don’t know how to install Tomcat you can get an idea from these good guides: How To Install Apache Tomcat | DigitalOcean. For yum package manager see guide for CentOS.

 

Next steps assumes Tomcat installed and running with user tomcat

Create TermWeb home folder

TermWeb home folder will be used for storing terweb.properties file, file uploads, temporary files and logs.

  • sudo mkdir /opt/twhome

  • sudo chown -R tomcat:tomcat /opt/twhome

Setup tomcat

You may configure Tomcat via systemd, init.d, startup command or with standard Tomcat file setenv.sh.

  • Create setenv.sh file at <tomcat_folder>/bin

    touch /opt/tomcat/bin/setenv.sh sudo chgrp tomcat /opt/tomcat/bin/setenv.sh
  • with following contents:

    export CATALINA_OPTS="-Xms1g -Xmx1g \ -Dspring.config.name=termweb \ -Dspring.profiles.active=mysql,termweb3-search \ -Dfile.encoding=UTF-8 \ -Duser.timezone=UTC \ -Dtermweb.home=/opt/twhome \ -verbose:gc"

    -Xms1g -Xmx1g stands for 1GB of java heap of Tomcat process.
    For server with RAM less than 4GB assign 50% to java heap. If bigger than 4GB then you can set about 75% of RAM to java heap.

  • Edit /opt/tomcat/conf/server.xml by adding next line to <Host> element, this will disable output of Tomcat version and stacktraces output:

    <Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false" />
  • If you have plans to use many languages per dictionary and user groups, like 30 languages and 50 user groups (multiplication result greater than 1000), you need to change default tomcat’s maximum accepted parameter count:
    in a file /opt/tomcat/conf/server.xml change:
    <Connector port="8080" protocol="HTTP/1.1" ... maxParameterCount="1000" />
    to:
    <Connector port="8080" protocol="HTTP/1.1" ... maxParameterCount="3000" />

6

Install or configure Apache httpd server

  • Simply install latest version by running:
    sudo yum install httpd

  • Add next lines to /etc/httpd/conf/httpd.conf to disable printing server version in http headers for security reasons:

  • Put next config to /etc/httpd/conf.d/hosts.conf or to any other virtual host file:

    localhost:8080 stands for Tomcat default port.

Enabling HTTP/2 for Apache httpd

Enabling HTTP/2 for TermWeb speeds up initial page render about 3x times especially for anonymous users.

Prior to enable HTTP/2 you must have at least Apache httpd 2.4.17

To enable HTTP/2 protocol for host use next config: Protocols h2 h2c http/1.1 for your virtual host config, like this:


If after restarting httpd (apachectl restart) HTTP/2 is not available then check next things:

  1. That you applied to both http and https connections new protocol

  2. That your httpd config has enabled MPM event in /etc/httpd/conf.modules.d/00-mpm.conf you need to uncomment there next line:

    Plus comment old one:

    And then restart httpd again.

7

Configure encryption for your website

Pickup certificate from your IT department or get from any company. One of non commercial companies provides it for free: https://letsencrypt.org

8

Install TermWeb 4

Unpack distributive

  • Unpack TermWeb distributive:
    unzip termweb-4.0.8-6.zip

  • Unpack and move contents of termweb-4.0.8-6.war (it’s regular zip archive) into <tomcat_folder>/webapps/ROOT folder (don't forget to cleanup it first by removing all preinstalled files, if you’re not using Tomcat manager):
    sudo unzip termweb-4.0.8-6.war -d /opt/tomcat/webapps/ROOT

  • Download and install mysql-connector-j into /opt/tomcat/webapps/ROOT/WEB-INF/lib
    Go to https://dev.mysql.com/downloads/connector/j/ and select platform independent version of connector compatible with MySQL version 8.0

    Unpack and move it to lib folder mentioned before:
    tar xf mysql-connector-j-8.0.33.tar.gz && cp mysql-connector-j-8.0.33/mysql-connector-j-8.0.33.jar /opt/tomcat/webapps/ROOT/WEB-INF/lib

  • Make all files accessible by tomcat
    sudo chown -R tomcat:tomcat /opt/tomcat/webapps/ROOT

  • Unpack termweb-ui.zip archive and copy contents of dist folder into /var/www:
    unzip termweb-ui-4.0.8-6.zip -d termweb-ui/
    sudo mkdir /var/www/termweb4
    sudo cp -a /home/ec2-user/termweb-ui/dist/. /var/www/termweb4/
    sudo chown -R apache: /var/www/termweb4/
    sudo chmod -R 400 /var/www/termweb4
    sudo find /var/www/termweb4 -type d -exec chmod u+x {} \;
    sudo restorecon -R -v /var/www/termweb4

Create and configure termweb.properties

  • Create and open for editing the unit file by running this command:
    /opt/twhome/termweb.properties

  • To be able to start successfully TermWeb you need to configure at least this properties:

For further configuration check next page: TermWeb configuration (termweb.properties)

Run and test

  • Restart apache httpd to be able to see website
    sudo apachectl restart

  • Start tomcat, first launch will take about 2-5 minutes to create everything in database:
    sudo service tomcat start

  • Check tomcat logs for errors in file /opt/tomcat/logs/catalina.out

  • Login as administrator with default credentials (default credentials can be found in a file <termweb.home>/initial.conf)

9

Configure log rotation for Tomcat

To avoid tomcat logs grow without limits we need to configure logrotate for it. Major log file to rotate there is <tomcat_folder>/logs/catalina.out

10

Configure Monitoring for server status

We advise to configure tools on your choice which will monitor server status

11

Configure DB backups

Don’t forget to have DB backups on daily basis.