/
1.3.4. Install and customize Tomcat server

1.3.4. Install and customize Tomcat server

The Apache Tomcat server will serve as the execution environment for various web applications and services. Within this system will be housed the following applications:

     1. Certificate Manage

     2 . b+ SII Dashboard

     3. Dashboard web services

     4. Tenant configuration of the integration system
     

  • Download Tomcat 8

We create support scripts for Tomcat 8 to facilitate the start and stop operations of the server.

1-      Download Apache Tomcat 8
Use ~/Downloads/bundle_fuse/JAVA/SERVERS/ as download path

Filename: Download Apache Tomcat 8.5.11

apache-tomcat-8.5.11.tar.gz
https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.11/bin/apache-tomcat-8.5.11.tar.gz 

2-      Instalación de Apache Tomcat 8 

The contents of the compressed are extracted in ~/sii/tomcat/
cd ~
mkdir -pv sii/tomcat
cd sii/tomcat/
cp ~/Downloads/bundle_fuse/JAVA/SERVERS/apache-tomcat-8.5.11.tar.gz .
tar xzf apache-tomcat-8.5.11.tar.gz
rm apache-tomcat-8.5.11.tar.gz


3-      Change the admin password for Apache Tomcat 8

Edit the Tomcat user configuration file and change the password to change it

vim ~/sii/tomcat/apache-tomcat-8.5.11/conf/tomcat-users.xml

Contens of tomcat-users.xml


 (...)
-->
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <user roles="manager-gui, manager-status " password="·····" username="admin"/>
</tomcat-users>



  • Creating support scripts for Tomcat 8

Creating support scripts for Tomcat 8

1-      Create files to fill

cd ~
cd bin
touch startTomcat8511
touch stopTomcat8511
chmod ugo+x startTomcat8511 stopTomcat8511

2-     Fill in the scripts with their respective contents

Contents of ~/bin/startTomcat8511 

 #!/bin/bash
export JAVA_HOME=/usr/local/jdk1.7.0_80
export JRE_HOME=/usr/local/jdk1.7.0_80
export CATALINA_HOME=$HOME/sii/tomcat/apache-tomcat-8.5.11
export PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$PATH
echo $JAVA_HOME
echo $JRE_HOME
echo $PATH
$CATALINA_HOME/bin/startup.sh 

Contents of ~/bin/stopTomcat8511 

#!/bin/bash
export JAVA_HOME=/usr/local/jdk1.7.0_80
export JRE_HOME=/usr/local/jdk1.7.0_80
export CATALINA_HOME=$HOME/sii/tomcat/apache-tomcat-8.5.11
export PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$PATH
echo $JAVA_HOME
echo $JRE_HOME
echo $PATH
$CATALINA_HOME/bin/shutdown.sh


3-      Add alias for scripts to: .bashrc

Edit ~/.bashrc y añadir las siguientes líneas

alias STARTTOMCAT8511='/bin/bash $HOME/bin/startTomcat8511'
alias STOPTOMCAT8511='/bin/bash $HOME/bin/stopTomcat8511'
alias LOGTOMCAT8511='tail -f $HOME/sii/tomcat/apache-tomcat-8.5.11/logs/catalina.out'


  • Booting Tomcat 8

    1-      Test Boot and Pause Scripts for Tomcat.
    Booting Tomcat allows you to create the localhost folder: 
    ~/sii/tomcat/apache-tomcat-8.5.11/conf/Catalina/localhost

    2-  To allow access from any network
    Edit the manager.xml file in the directory, for remote access:

    ~/sii/tomcat/apache-tomcat-8.5.11/conf/Catalina/localhost

    Contenidos de manager.xml

    <?xml version='1.0' encoding='utf-8'?>
    <!--
      Licensed to the Apache Software Foundation (ASF)
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
          http://www.apache.org/licenses/LICENSE-2.0
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License. -->
    <!-- The contents of this file will be loaded for each web application -->
    <Context privileged="true" antiResourceLocking="false"
             docBase="${catalina.home}/webapps/manager">
        <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.$"* />
    </Context>

    3-      Edit the server configuration
    We change the ports used by default to secure the server

    Edit file:
    /home/fuseadmin/sii/tomcat/apache-tomcat-8.5.11/conf/server.xml
     

    It is replaced by text editor, replacing all instances of ort = "8 for ort =" 9. Changing all ports starting with 8 to ports starting with 9

    In vim it can be done with the following command:
           :%s/ort="8/ort="9/g

  • Additional settings for Tomcat

    1-      Stop and replicate host_manager and examples, so you can remove them

    2-      Block access to the application, allowing only access from localhost.

    3-      IPV6 is disabled as described at https://access.redhat.com/solutions/8709

    4-   IPV6 is disabled at file /etc/sysconfig/network/ifcfg-eth0

    5-      Add the following lines a/etc/default/grub

    6-      Enable configuration changes

    grub2-mkconfig -o /boot/grub2/grub.cfg

Avvale 2024