此内容没有您所选择的语言版本。
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) 复制链接链接已复制到粘贴板!
Before installing JBoss Web Server, you must first install a supported Java Development Kit (JDK).
For a list of supported JDKs for Red Hat JBoss Web Server 5.0, see: JBoss Web Server 5 Supported Configurations.
The installation of the OpenJDK or the IBM JDK are presented here. To install the Oracle JDK, follow the instructions provided by Oracle at: http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Installing a JDK using the YUM package manager
Subscribe your Red Hat Enterprise Linux system to the appropriate channel:
OpenJDK:
- rhel-6-server-rpms
- rhel-7-server-rpms
IBM:
- rhel-6-server-supplementary-rpms
- rhel-7-server-supplementary-rpms
As the root user, execute the command to install a 1.8 JDK:
yum install java-1.8.0-<VENDOR>-devel
# yum install java-1.8.0-<VENDOR>-devel
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<VENDOR>
withibm
oropenjdk
.Run the following commands as the root user to ensure the correct JDK is in use:
alternatives --config java
# alternatives --config java
Copy to Clipboard Copied! Toggle word wrap Toggle overflow alternatives --config javac
# alternatives --config javac
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.ImportantAll software that use the
java
andjavac
commands uses the JDK set byalternatives
. Changing Java alternatives may impact on the running of other software.
Installing a JDK from a compressed archive (such as .zip or .tar)
If the JDK was downloaded from the vendor’s website (Oracle, IBM 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
$ cat JWS_HOME/tomcat/bin/setenv.sh
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64
2.1.2. 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.
-
You must remove the
tomcatjss
package before installing thetomcat-native
package. Thetomcatjss
package uses an underlying NSS security model rather than the OpenSSL security model.
Removing the tomcatjss Package
As the root user, run the following command to remove
tomcatjss
:yum remove tomcatjss
# yum remove tomcatjss
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. ZIP Installation 复制链接链接已复制到粘贴板!
Ensure that all of the prerequisites are met before installing JBoss Web Server.
2.2.1. Downloading and Extracting JBoss Web Server 复制链接链接已复制到粘贴板!
To install JBoss Web Server, download and extract the installation ZIP files.
- Open a browser and log in to the Red Hat Customer Portal.
- Click Downloads.
- Click Red Hat JBoss Web Server in the Product Downloads list.
- Select the correct JBoss Web Server version from the Version drop-down menu.
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.0 Application Server (
jws-application-servers-5.0.0.zip
). -
The Red Hat JBoss Web Server 5.0 Native Components for RHEL (
jws-application-servers-5.0.0-<platform>-<architecture>.zip
).
-
The Red Hat JBoss Web Server 5.0 Application Server (
Unzip the downloaded ZIP files to your installation directory.
For example:
unzip jws-application-server-5.0.0.zip -d /opt/ unzip -o jws-application-server-5.0.0-<platform>-<architecture>.zip -d /opt/
# unzip jws-application-server-5.0.0.zip -d /opt/ # unzip -o jws-application-server-5.0.0-<platform>-<architecture>.zip -d /opt/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The directory created by extracting the ZIP archives is the top-level directory for JBoss Web Server. This is referred to as JWS_HOME
.
There is three 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.
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 7 is systemd and for Red Hat Enterprise Linux 6 the default is SysV.
To determine which system daemon is running, issue ps -p 1 -o comm=
.
For systemd:
ps -p 1 -o comm=
$ ps -p 1 -o comm= systemd
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For SysV:
ps -p 1 -o comm=
$ ps -p 1 -o comm= init
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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
# 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
# chkconfig jws5-tomcat on
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To start the JBoss Web Server using SysV:
service jws5-tomcat start
# service jws5-tomcat start
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To stop the JBoss Web Server using SysV:
service jws5-tomcat stop
# service jws5-tomcat stop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify the status of the JBoss Web Server using SysV (the
status
operation can be executed by any user):service jws5-tomcat status
$ service jws5-tomcat status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information on using SysV, see: Red Hat Enterprise Linux 6 Deployment Guide: Running Services
Setting up the JBoss Web Server for systemd
As the root user, execute the .postinstall.systemd
script:
cd JWS_HOME/tomcat sh .postinstall.systemd
# 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
# systemctl enable jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To start the JBoss Web Server using systemd:
systemctl start jws5-tomcat.service
# systemctl start jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To stop the JBoss Web Server using systemd:
systemctl stop jws5-tomcat.service
# systemctl stop jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
# systemctl status jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information on using systemd, see: Red Hat Enterprise Linux 7 System Administrator’s Guide: Managing System Services
2.2.2.2. Managing JBoss Web Server on a command line 复制链接链接已复制到粘贴板!
2.2.2.2.1. Configuring the JBoss Web Server Installation 复制链接链接已复制到粘贴板!
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.
- Creating the tomcat user for simple and secure user management: Creating a Tomcat User.
- Grant the tomcat user access to the JBoss Web Server by moving the ownership of tomcat directory to the tomcat user.
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:
-
In a shell prompt as the root user, change directory to
JWS_HOME
. Run the following command to create the
tomcat
user group:groupadd -g 53 -r tomcat
# groupadd -g 53 -r tomcat
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following command to create the
tomcat
user in thetomcat
user group:useradd -c "tomcat" -u 53 -g tomcat -s /bin/sh -r tomcat
# useradd -c "tomcat" -u 53 -g tomcat -s /bin/sh -r tomcat
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Move the ownership of tomcat directory to the tomcat user
From
JWS_HOME
, run the following command to assign the ownership of the Tomcat directories to thetomcat
user to allow the user to run the Tomcat service:chown -R tomcat:tomcat tomcat/
# chown -R tomcat:tomcat tomcat/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can use
ls -l
to verify that thetomcat
user is the owner of the directory.Ensure that the
tomcat
user has execute permissions to all parent directories. For example:chmod -R u+X tomcat/
# chmod -R u+X tomcat/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.2.2.2. Starting JBoss Web Server 复制链接链接已复制到粘贴板!
Run the following command as the tomcat
user:
sh JWS_HOME/tomcat/bin/startup.sh
$ 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
$ 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 only available for Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7.
RPM installation packages for JBoss Web Server are available from Red Hat Subscription Management.
2.3.1. Installing JBoss Web Server from RPM packages 复制链接链接已复制到粘贴板!
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 Configuring the Subscription Service for Red Hat Enterprise Linux 6 or The Subscription Manager for Red Hat Enterprise Linux 7.
Attaching subscriptions to Red Hat Enterprise Linux (if required)
If the system does not have a subscription attached that provides JBoss Web Server:
- Log in to the Red Hat Subscription Manager.
- Click on the Systems tab.
-
Click on the
Name
of the system to add the subscription to. -
Change from the Details tab to the Subscriptions tab, then click
Attach Subscriptions
. -
Select the check box beside the subscription to attach, then click
Attach Subscriptions
.
To verify that a subscription provides the required CDN repositories:
- Log in to: https://access.redhat.com/management/subscriptions.
-
Click the
Subscription Name
. Under Products Provided, you require:
- JBoss Enterprise Web Server.
- Red Hat JBoss Core Services.
Installing JBoss Web Server from RPM packages using YUM
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>
# subscription-manager repos --enable <repository>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
Issue the following command as the root user to install JBoss Web Server:
yum groupinstall jws5
# yum groupinstall jws5
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.
2.3.2. Starting JBoss Web Server 复制链接链接已复制到粘贴板!
In a shell prompt as the root user, start the Tomcat service.
For Red Hat Enterprise Linux 6:
service jws5-tomcat start
# service jws5-tomcat start
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl start jws5-tomcat.service
# systemctl start jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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
# service jws5-tomcat status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl status jws5-tomcat.service
# systemctl status jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3.3. Stopping JBoss Web Server 复制链接链接已复制到粘贴板!
In a shell prompt as the root user, stop the Tomcat service.
For Red Hat Enterprise Linux 6:
service jws5-tomcat stop
# service jws5-tomcat stop
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl stop jws5-tomcat.service
# systemctl stop jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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
# service jws5-tomcat status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl status jws5-tomcat.service
# systemctl status jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Use the following commands to enable the JBoss Web Server services to start at boot.
For Red Hat Enterprise Linux 6:
chkconfig jws5-tomcat on
# chkconfig jws5-tomcat on
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl enable jws5-tomcat.service
# systemctl enable jws5-tomcat.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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.
Name | Port Information | Policy Information |
---|---|---|
jws5_tomcat |
Four ports in |
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 |
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.0, install the jws5-tomcat-selinux
package.
2.4.3. SELinux Policies for a ZIP Installation 复制链接链接已复制到粘贴板!
In this release, SELinux policies are provided in the ZIP 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-application-server-5.0.0-<platform>-<architecture>.zip
. If required, you can run the .postinstall.selinux
script.
To install the SELinux policies using ZIP:
Install the
selinux-policy-devel
package:yum install -y selinux-policy-devel
yum install -y selinux-policy-devel
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Execute the
.postinstall.selinux
script:cd <JWS_home>/tomcat/ sh .postinstall.selinux
cd <JWS_home>/tomcat/ sh .postinstall.selinux
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make and install the SELinux module:
cd selinux make -f /usr/share/selinux/devel/Makefile semodule -i jws5-tomcat.pp
cd selinux make -f /usr/share/selinux/devel/Makefile semodule -i jws5-tomcat.pp
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the SELinux contexts for JBoss Web Server:
restorecon -r <JWS_home>/tomcat/
restorecon -r <JWS_home>/tomcat/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add access permissions to the required ports for JBoss Web Server. The JBoss Web Server has access to ports
8080
,8009
,8443
and8005
on Red Hat Enterprise Linux 7 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>
semanage port -a -t http_port_t -p tcp <port>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe JBoss Web Server on Red Hat Enterprise Linux 6 systems has access to the same ports as Red Hat Enterprise Linux 7 systems, with the exception of port
8005
. To grant the JBoss Web Server access to this port on a Red Hat Enterprise Linux 6 system, as the root user, issue:semanage port -a -t http_port_t -p tcp 8005
semanage port -a -t http_port_t -p tcp 8005
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start the Tomcat service:
<JWS_home>/tomcat/bin/startup.sh
<JWS_home>/tomcat/bin/startup.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the context of the running process expecting
jws5_tomcat
:ps -eo pid,user,label,args | grep jws5_tomcat | head -n1
ps -eo pid,user,label,args | grep jws5_tomcat | head -n1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify the contexts of the Tomcat directories, for example:
ls -lZ <JWS_home>/tomcat/logs/
ls -lZ <JWS_home>/tomcat/logs/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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.