Chapter 2. Installing JBoss Web Server on Red Hat Enterprise Linux

You can install JBoss Web Server on Red Hat Enterprise Linux using one of two methods:

Regardless of which method you choose, you must first install a supported Java Development Kit (JDK).

2.1. Prerequisites

2.1.1. Installing a Java Development Kit (JDK) using the YUM package manager

Before installing JBoss Web Server, you must first install a supported Java Development Kit (JDK).

For a completed list of supported JDKs see Supported operating systems and configurations.

Procedure

  1. Subscribe your Red Hat Enterprise Linux system to the appropriate channel:

    • OpenJDK:

      • rhel-6-server-rpms
      • rhel-7-server-rpms
      • rhel-8-server-rpms
    • IBM:

      • rhel-6-server-supplementary-rpms
      • rhel-7-server-supplementary-rpms
      • rhel-8-server-supplementary-rpms
  2. As the root user, execute the command to install a 1.8 JDK:

    # yum install java-1.8.0-<VENDOR>-devel

    Replace <VENDOR> with ibm or openjdk

  3. Run the following commands as the root user to ensure the correct JDK is in use:

    # alternatives --config java
    # alternatives --config javac

    These commands return lists of available JDK versions with the selected version marked with a plus (+) sign. If the selected JDK is not the desired one, change to the desired JDK as instructed in the shell prompt.

    Important

    All software that use the java and javac commands uses the JDK set by alternatives. Changing Java alternatives may impact on the running of other software.

2.1.2. Installing a JDK from a compressed archive (such as .zip or .tar)

Before installing JBoss Web Server, you must first install a supported Java Development Kit (JDK).

A full list of supported JDKs is given in section 1.2 of this document.

If the JDK was downloaded from the vendor’s website (Oracle or OpenJDK), use the installation instructions provided by the vendor and set the JAVA_HOME environment variable.

If the JDK has was installed from a compressed archive, set the JAVA_HOME environment variable for Tomcat before running JBoss Web Server.

In the bin directory of Tomcat (JWS_HOME/tomcat/bin), create a file named setenv.sh, and insert the JAVA_HOME path definition.

For example:

$ cat JWS_HOME/tomcat/bin/setenv.sh

export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64

2.1.3. Red Hat Enterprise Linux Package Prerequisites

Before installing JBoss Web Server on Red Hat Enterprise Linux, ensure the following prerequisites are met.

  • A supported JDK is installed.
  • Additionally, RHEL-8 users needing to run JSSE+OpenSSL or APR, you will need to use Tomcat-Native for it to work properly. The file for Tomcat-Native can be found in the native archive directory. To install OpenSSL and APR, run the following commands:

    # yum install openssl
    # yum install apr
  • You must remove the tomcatjss package before installing the tomcat-native package. The tomcatjss package uses an underlying NSS security model rather than the OpenSSL security model.

    • As the root user, run the following command to remove tomcatjss:

      # yum remove tomcatjss

2.2. Installing and Managing JBoss Web Server (ZIP)

You can install JBoss Web Server from an archive file. Installation from an archive results in different methods of managing the product compared to installation from an RPM package. For example, you can use a system daemon at boot time and manage JBoss Web Server from a command line. Start by downloading and extracting the archive file.

2.2.1. Downloading and Extracting JBoss Web Server

This method of installation involves accessing the Red Hat Customer Portal and locating the correct version of JBoss Web Server.

Prerequisites

Procedure

To install JBoss Web Server, download and extract the installation archive files.

  1. Open a browser and log in to the Red Hat Customer Portal.
  2. Click Downloads.
  3. Click Red Hat JBoss Web Server in the Product Downloads list.
  4. Select the correct JBoss Web Server version from the Version drop-down menu.
  5. Click Download for each of the following files, ensuring that you select the correct platform and architecture for your system:

    • The Red Hat JBoss Web Server 5.3 Application Server (jws-5.3.0-application-server.zip).
    • The Red Hat JBoss Web Server 5.3 Native Components for RHEL (jws-5.3.0-application-server-<platform>-<architecture>.zip).
  6. Unzip the downloaded archive files to your installation directory.

    For example:

    # unzip jws-5.2.0-application-server.zip -d /opt/
    # unzip -o jws-5.2.0-application-server-<platform>-<architecture>.zip -d /opt/

The directory created by extracting the archives is the top-level directory for JBoss Web Server. This is referred to as JWS_HOME.

2.2.2. Managing JBoss Web Server on Red Hat Enterprise Linux

There are two supported methods for running and managing Red Hat JBoss Web Server on Red Hat Enterprise Linux:

The recommended method for managing the JBoss Web Server is using a system daemon.

2.2.2.1. Managing JBoss Web Server using a system daemon for .zip installations on Red Hat Enterprise Linux

Using the JBoss Web Server with a system daemon provides a method of starting the JBoss Web Server services at system boot. The system daemon also provides start, stop and status check functions.

The default system daemon for Red Hat Enterprise Linux 8 and Red Hat Enterprise Linux 7 is systemd and for Red Hat Enterprise Linux 6 the default is SysV.

Note

To determine which system daemon is running, issue ps -p 1 -o comm=.

  • For systemd:

    $ ps -p 1 -o comm=
    
    systemd
  • For SysV:

    $ ps -p 1 -o comm=
    
    init
2.2.2.1.1. Setting up and using the JBoss Web Server with SysV
Prerequisites
  • The redhat-lsb-core package. To install, run: yum install redhat-lsb-core
Setting up the JBoss Web Server for SysV

As the root user, execute the .postinstall.sysv script:

# cd JWS_HOME/tomcat
# sh .postinstall.sysv
Controlling the JBoss Web Server with SysV

SysV commands can only be issued by the root user.

  • To enable the JBoss Web Server services to start at boot using SysV:

    # chkconfig jws5-tomcat on
  • To start the JBoss Web Server using SysV:

    # service jws5-tomcat start
  • To stop the JBoss Web Server using SysV:

    # service jws5-tomcat stop
  • To verify the status of the JBoss Web Server using SysV (the status operation can be executed by any user):

    $ service jws5-tomcat status

For more information on using SysV, see: Red Hat Enterprise Linux 6 Deployment Guide: Running Services

2.2.2.1.2. Setting up and using the JBoss Web Server with systemd
Setting up the JBoss Web Server for systemd

As the root user, execute the .postinstall.systemd script:

# cd JWS_HOME/tomcat
# sh .postinstall.systemd
Controlling the JBoss Web Server with systemd

Systemd commands can only be issued by the root user.

  • To enable the JBoss Web Server services to start at boot using systemd:

    # systemctl enable jws5-tomcat.service
  • To start the JBoss Web Server using systemd:

    # systemctl start jws5-tomcat.service
  • To stop the JBoss Web Server using systemd:

    # systemctl stop jws5-tomcat.service
  • To verify the status of the JBoss Web Server using systemd (the status operation can be executed by any user):

    # systemctl status jws5-tomcat.service

For more information on using systemd on RHEL 7, see: RHEL 7 System Administrator’s Guide: Managing System Services

For more information on using systemd on RHEL 8, see: RHEL 8 Configuring Basic System Settings: Managing system services with systemctl

2.2.2.2. Managing JBoss Web Server on a command line

2.2.2.2.1. Configuring the JBoss Web Server Installation
Note

The following configuration steps are performed by the .postinstall.sysv script and the .postinstall.systemd script described in Managing JBoss Web Server using a system daemon for .zip installations on Red Hat Enterprise Linux

Some configuration is required before running JBoss Web Server. This section includes the following configuration procedures:

Setting the JAVA_HOME Environment Variable

You must set the JAVA_HOME environment variable for Tomcat before running JBoss Web Server.

In the bin directory of Tomcat (JWS_HOME/tomcat/bin), create a file named setenv.sh, and insert the JAVA_HOME path definition.

For example: export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64

Creating a Tomcat User

Follow this procedure to create the tomcat user and its parent group:

  1. In a shell prompt as the root user, change directory to JWS_HOME.
  2. Run the following command to create the tomcat user group:

    # groupadd -g 53 -r tomcat
  3. Run the following command to create the tomcat user in the tomcat user group:

    # useradd -c "tomcat" -u 53 -g tomcat -s /sbin/nologin -r tomcat
Move the ownership of tomcat directory to the tomcat user
  1. From JWS_HOME, run the following command to assign the ownership of the Tomcat directories to the tomcat user to allow the user to run the Tomcat service:

    # chown -R tomcat:tomcat tomcat/

    You can use ls -l to verify that the tomcat user is the owner of the directory.

  2. Ensure that the tomcat user has execute permissions to all parent directories. For example:

    # chmod -R u+X tomcat/
2.2.2.2.2. Starting JBoss Web Server

Run the following command as the tomcat user:

$ sh JWS_HOME/tomcat/bin/startup.sh
2.2.2.2.3. Stopping JBoss Web Server

To stop Tomcat, run the following command as the tomcat user:

$ sh JWS_HOME/tomcat/bin/shutdown.sh

2.3. RPM Installation

Installing JBoss Web Server from RPM packages installs Tomcat as service, and installs its resources into absolute paths. The RPM installation option is available for Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7, and Red Hat Enterprise Linux 8.

RPM installation packages for JBoss Web Server are available from Red Hat Subscription Management.

2.3.1. Attaching subscriptions to Red Hat Enterprise Linux

Before downloading and installing the RPM packages, you must register your system with Red Hat Subscription Management and subscribe to the respective Content Delivery Network (CDN) repositories.

For information on registering Red Hat Enterprise Linux, see the following procedures:

Procedure

  1. Log in to the Red Hat Subscription Manager.
  2. Click on the Systems tab.
  3. Click on the Name of the system to add the subscription to.
  4. Change from the Details tab to the Subscriptions tab, then click Attach Subscriptions.
  5. Select the check box beside the subscription to attach, then click Attach Subscriptions.
Note

To verify that a subscription provides the required CDN repositories:

  1. Log in to: https://access.redhat.com/management/subscriptions.
  2. Click the Subscription Name.
  3. Under Products Provided, you require:

    • JBoss Enterprise Web Server.
    • Red Hat JBoss Core Services.

2.3.2. Installing JBoss Web Server from RPM packages using YUM

Procedure

  1. On a command line, subscribe to the JBoss Web Server CDN repositories for your operating system version using subscription-manager:

    # subscription-manager repos --enable <repository>
    • For Red Hat Enterprise Linux 6:

      • jws-5-for-rhel-6-server-rpms
      • jb-coreservices-1-for-rhel-6-server-rpms
    • For Red Hat Enterprise Linux 7:

      • jws-5-for-rhel-7-server-rpms
      • jb-coreservices-1-for-rhel-7-server-rpms
    • For Red Hat Enterprise Linux 8:

      • jws-5-for-rhel-8-x86_64-rpms
  2. Issue the following command as the root user to install JBoss Web Server:

    # yum groupinstall jws5
    Important

    For RPM distributions, the JWS_HOME folder is /opt/rh/jws5/root/usr/share.

Note
  • Although not recommended, instead of using the group install, you can install each of the packages and their dependencies individually.
  • The Red Hat JBoss Core Services repositories above are required for the installation of JBoss Web Server except on RHEL 8 systems.

2.3.3. Starting JBoss Web Server

This procedure demonstrates how you can start the JBoss Web Server.

Procedure

  • In a shell prompt as the root user, start the Tomcat service.

    • For Red Hat Enterprise Linux 6:

      # service jws5-tomcat start
    • For Red Hat Enterprise Linux 7 or 8:

      # systemctl start jws5-tomcat.service
      Note

      This is the only supported method of starting JBoss Web Server for an RPM installation.

  • To verify that Tomcat is running, the output of the service status command should be reviewed. This can be executed as any user.

    • For Red Hat Enterprise Linux 6:

      # service jws5-tomcat status
    • For Red Hat Enterprise Linux 7 or 8:

      # systemctl status jws5-tomcat.service
      Note

      For complete instructions on installing and configuring HTTPD on RHEL 8, please see this link

2.3.4. Stopping JBoss Web Server

This procedure demonstrates how you can stop the JBoss Web Server.

Procedure

  • In a shell prompt as the root user, stop the Tomcat service.

    • For Red Hat Enterprise Linux 6:

      # service jws5-tomcat stop
    • For Red Hat Enterprise Linux 7 or 8:

      # systemctl stop jws5-tomcat.service
  • To verify that Tomcat is no longer running, the output of the service status command should be reviewed. This can be executed as any user.

    • For Red Hat Enterprise Linux 6:

      # service jws5-tomcat status
    • For Red Hat Enterprise Linux 7 or 8:

      # systemctl status jws5-tomcat.service
Note

For complete instructions on installing and configuring HTTPD on RHEL 8, please see this link

2.3.5. Configuring JBoss Web Server Services to Start at Boot

Use the following commands to enable the JBoss Web Server services to start at boot.

Procedure

  • Depending on your Red Hat Enterprise Linux version, enter one of the following commands:

    • For Red Hat Enterprise Linux 6:

      # chkconfig jws5-tomcat on
    • For Red Hat Enterprise Linux 7 or 8:

      # systemctl enable jws5-tomcat.service

2.4. SELinux Policies

2.4.1. SELinux Policy Information

The following table contains information about the SELinux policies provided in the jws5-tomcat-selinux packages.

Table 2.1. RPMs and Default SELinux Policies

NamePort InformationPolicy Information

jws5_tomcat

Four ports in http_port_t (TCP ports 8080, 8005, 8009, and 8443) to allow the tomcat process to use them.

The jws5_tomcat policy is installed, which sets the appropriate SELinux domain for the process when Tomcat executes. It also sets the appropriate contexts to allow tomcat to write to /var/opt/rh/jws5/lib/tomcat, /var/opt/rh/jws5/log/tomcat, /var/opt/rh/jws5/cache/tomcat and /var/opt/rh/jws5/run/tomcat.pid.

For more information about using SELinux and other Red Hat Enterprise Linux security information, see the Red Hat Enterprise Linux Security Guide.

2.4.2. SELinux policies for an RPM installation

SELinux policies for JBoss Web Server are provided by the jws5-tomcat-selinux package. These packages are available in the JWS channel.

To enable SELinux policies for JBoss Web Server 5.3, install the jws5-tomcat-selinux package.

2.4.3. SELinux policies for an archive installation

In this release, SELinux policies are provided in the archive packages. The SELinux security model is enforced by the kernel and ensures applications have limited access to resources such as file system locations and ports. This helps ensure that the errant processes (either compromised or poorly configured) are restricted and in some cases prevented from running.

The .postinstall.selinux file is included in the tomcat folder of jws-5.3.0-application-server-<platform>-<architecture>.zip. If required, you can run the .postinstall.selinux script.

To install the SELinux policies using archive:

  1. Install the selinux-policy-devel package:

    yum install -y selinux-policy-devel
  2. Execute the .postinstall.selinux script:

    cd <JWS_home>/tomcat/
    sh .postinstall.selinux
  3. Add access permissions to the required ports for JBoss Web Server. The JBoss Web Server has access to ports 8080, 8009, 8443 and 8005 on Red Hat Enterprise Linux systems.

    When additional ports are required for JBoss Web Server, use the semanage command to provide the necessary permissions, replacing the port number with the port required:

    semanage port -a -t http_port_t -p tcp <port>
  4. Start Tomcat:

    <JWS_home>/tomcat/bin/startup.sh
  5. Check the context of the running process expecting jws5_tomcat:

    ps -eo pid,user,label,args | grep jws5_tomcat | head -n1
  6. To verify the contexts of the Tomcat directories, for example:

    ls -lZ <JWS_home>/tomcat/logs/
Note

By default, the SElinux policy provided is not active and the Tomcat processes run in the unconfined_java_t domain. This domain does not confine the processes, and it is recommended that you undertake the following security precautions if you chose not to enable the SElinux policy provided:

  • Restrict file access for the tomcat user to only the files and directories that are necessary to the JBoss Web Server runtime.
  • Do not run Tomcat as the root user.