In this blog post, we will discuss the steps used to Install WildFly (JBoss) Server on CentOS 8 / CentOS 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 JDK

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

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

sudo yum install java-11-openjdk-devel

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

$ java --version
openjdk 11.0.13 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

Step 2: Download WildFly Release archive

Check WildFly Downloads page for latest releases before downloading the file.

sudo yum -y install wget curl
WILDFLY_RELEASE=$(curl -s https://api.github.com/repos/wildfly/wildfly/releases/latest|grep tag_name|cut -d '"' -f 4)
wget https://github.com/wildfly/wildfly/releases/download/${WILDFLY_RELEASE}/wildfly-${WILDFLY_RELEASE}.tar.gz

Once the file is downloaded, extract it.

tar xvf wildfly-${WILDFLY_RELEASE}.tar.gz

Move resulting folder to /opt/wildfly.

sudo mv wildfly-${WILDFLY_RELEASE} /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 2023-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.

$ sudo 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 to the system

WildFly is 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):  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
Authenticating against security realm: ManagementRealm
Username: <enter-created-username>
Password: <enter-assigned-password>
[standalone@localhost:9990 /] version
JBoss Admin Command-line Interface
JBOSS_HOME: /opt/wildfly
Release: 29.0.1.Final
Product: WildFly Full 29.0.1.Final
JAVA_HOME: null
java.version: 11.0.13
java.vm.vendor: Red Hat, Inc.
java.vm.version: 11.0.13+8-LTS
os.name: Linux
os.version: 4.18.0-305.7.1.el8_4.x86_64
[standalone@localhost:9990 /] exit

Accessing WildFly Admin Console from Web Interface

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

$ sudo 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.

wildfly console login rhel centos8

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

wildfly web console

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


LEAVE A REPLY

Please enter your comment!
Please enter your name here