(Last Updated On: April 3, 2019)

In this blog post., we will discuss the steps used to Install WildFly (JBoss) Application Server on RHEL / CentOS 8/7.  WildFly formerly known as JBoss is an application server written in Java and developed by Red Hat. It is an exceptionally fast, lightweight and powerful implementation of the Java Enterprise Edition 8 Platform specifications.

Setup Pre-requisites

  • CentOS / RHEL 8 or CentOS / RHEL 7 server
  • Java runtime environment
  • User with sudo or root access
  • Internet connection on your Server

Step 1: Install Java

Java is required on the server that will run WildFly Application Server. Use our guides below to install Java on CentOS / RHEL 7&8.

How to Install Java 11 (OpenJDK 11) on RHEL / CentOS 8

How to Install Java 11 on CentOS 7

If you want to go with Java 8, then just run the commands below to install it.

sudo yum install java-1.8.0-openjdk-devel

You can check the default Java version in your machine using:

$ java --version
openjdk version "11-ea" 2018-09-25
OpenJDK Runtime Environment (build 11-ea+28)
OpenJDK 64-Bit Server VM (build 11-ea+28, mixed mode, sharing)

Step 2: Download WildFly

Check WildFly Downloads page for latest releases before downloading the file. Here we will download WildFly 16.0.0.Final.

sudo yum -y install wget
export WILDFLY_RELEASE="16.0.0"
wget https://download.jboss.org/wildfly/$WILDFLY_RELEASE.Final/wildfly-$WILDFLY_RELEASE.Final.tar.gz

Once the file is downloaded, extract it.

tar xvf wildfly-$WILDFLY_RELEASE.Final.tar.gz

Move resulting folder to /opt/wildfly.

sudo mv wildfly-$WILDFLY_RELEASE.Final/ /opt/wildfly

Step 3: Configure Systemd for WildFly

Let’s now create a system user and group that will run WildFly service.

sudo groupadd --system wildfly
sudo useradd -s /sbin/nologin --system -d /opt/wildfly -g wildfly wildfly

Create WildFly configurations directory.

sudo mkdir /etc/wildfly

Copy WildFly systemd service, configuration file and start scripts templates from the /opt/wildfly/docs/contrib/scripts/systemd/ directory.

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
sudo chmod +x /opt/wildfly/bin/launch.sh

Set /opt/wildfly permissions.

sudo chown -R wildfly:wildfly /opt/wildfly

Reload systemd service.

sudo systemctl daemon-reload

Configure SELinux:

sudo semanage fcontext  -a -t bin_t  "/opt/wildfly/bin(/.*)?"
sudo restorecon -Rv /opt/wildfly/bin/

Start and enable WildFly service:

sudo systemctl start wildfly
sudo systemctl enable wildfly

Confirm WildFly Application Server status.

$ systemctl status wildfly
● wildfly.service - The WildFly Application Server
Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-04-03 16:22:58 EAT; 6s ago
Main PID: 31303 (launch.sh)
Tasks: 119 (limit: 11510)
Memory: 330.8M
CGroup: /system.slice/wildfly.service
├─31303 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
├─31304 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
└─31396 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djbos>
Apr 03 16:22:58 rhel8.local systemd[1]: Started The WildFly Application Server.

Service should bind to port 8080.

# ss -tunelp | grep 8080
tcp LISTEN 0 128 0.0.0.0:8080 0.0.0.0:* users:(("java",pid=6854,fd=389)) uid:999 ino:30339 sk:3 <->

Step 4: Add WildFly Users

WildFly 16 is now distributed with security enabled for the management interfaces. We need to create a user who can access WildFly administration console or remotely use the CLI. A script is provided for managing users.

Run it by executing the command:

sudo /opt/wildfly/bin/add-user.sh

You will be asked to choose type of user to add. Since this the first user, we want to make it admin. So choose a.

What type of user do you wish to add? 
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a):

Provide desired username for the user.

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : computingforgeeks

Set password for the user:

Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
The password should be different from the username
The password should not be one of the following restricted values {root, admin, administrator}
The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
Password : <Enter Password>
Re-enter Password : <Confirm Password>

Press enter and agree to subsequent prompts to finish user creation.

What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: <Enter>
About to add user 'computingforgeeks' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'computingforgeeks' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'computingforgeeks' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'computingforgeeks' with groups to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'computingforgeeks' with groups to file '/opt/wildfly/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition

Notice that:

User information is kept on: /opt/wildfly/domain/configuration/mgmt-users.properties
Group information is kept on: /opt/wildfly/standalone/configuration/mgmt-groups.properties

Step 5: Accessing WildFly Admin Console

To be able to run WildFly scripts from you current shell session, add /opt/wildfly/bin/ to your $PATH.

cat >> ~/.bashrc <<EOF
export WildFly_BIN="/opt/wildfly/bin/"
export PATH=\$PATH:\$WildFly_BIN
EOF

Source the bashrc file.

source ~/.bashrc

Now test by connecting to WildFly Admin Console from CLI with jboss-cli.shcommand.

# jboss-cli.sh --connect
[[email protected]:9990 /] version
JBoss Admin Command-line Interface
JBOSS_HOME: /opt/wildfly
Release: 8.0.0.Final
Product: WildFly Full 16.0.0.Final
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-11.0.ea.28-8.el8.x86_64
java.version: 11-ea
java.vm.vendor: Oracle Corporation
java.vm.version: 11-ea+28
os.name: Linux
os.version: 4.18.0-32.el8.x86_64

Accessing WildFly Admin Console from Web Interface

By default, the console is accessible on localhost IP on port 9990.

# ss -tunelp | grep 9990
tcp    LISTEN   0    50    127.0.0.1:9990  0.0.0.0:* users:(("java",pid=6769,fd=404)) uid:999 ino:30407 sk:3 <-> 

We can start it on a different IP address accessible from outside the local server. Edit /opt/wildfly/bin/launch.sh to look like this:

.....
if [[ "$1" == "domain" ]]; then
$WILDFLY_HOME/bin/domain.sh -c $2 -b $3
else
$WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement=0.0.0.0
fi

We added -bmanagement=0.0.0.0 to start script line. This binds “management” interface to all available IP addresses.

Restart wildfly service

sudo systemctl restart wildfly

Confirm

$ ss -tunelp | grep 9990
tcp LISTEN 0 50 0.0.0.0:9990 0.0.0.0:* users:(("java",pid=9496,fd=320)) uid:999 ino:73367 sk:c <->

Open ports on firewall

sudo firewall-cmd --permanent --add-port={8080,9990}/tcp
sudo firewall-cmd --reload

Open your browser and URL http://serverip:9990 to access WildFly Web console.

Use username created earlier and password to authenticate. WildFly console will be the next window to show.

You have successfully installed WildFly Application server on RHEL / CentOS 8/7. Visit WildFly Documentation page for further reading.

If you’re an Ubuntu / Debian user, check: Install WildFly (JBoss) Application Server on Ubuntu 18.04 / Debian 10/9