Wildfly
Linux

How to install Wildfly on CentOS 8

WildFly (formerly known as JBoss) is an application server written in Java and developed by Red Hat. It is an open source application server for JEE applications, it is fast and lightweight and particularly efficient for web and business applications.

I will take you through the steps to install Wildfly sur CentOS 8.

Install JAVA :

Java is required on the server to run Wildfly, Follow our guide to install it on CentOS 8.

Once installed you can check the version with the command below :

[root@server ~]# java -version
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

Installer Wildfly :

Check this page to see the latest version of Wildfly.

[root@server ~]# wget https://download.jboss.org/wildfly/24.0.0.Final/wildfly-preview-24.0.0.Final.tar.gz
--2021-09-02 13:02:03-- https://download.jboss.org/wildfly/24.0.0.Final/wildfly-preview-24.0.0.Final.tar.gz
Resolving download.jboss.org (download.jboss.org)… 95.101.123.51, 95.101.123.88, 2a02:26f0:1d00::5f65:7b58, …
Connecting to download.jboss.org (download.jboss.org)|95.101.123.51|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 207638148 (198M) [application/x-gzip]
Saving to: ‘wildfly-preview-24.0.0.Final.tar.gz’

Once downloaded, extract the file :

[root@server ~]# tar xvf wildfly-preview-24.0.0.Final.tar.gz
[root@server ~]# ll
total 202776
drwxr-xr-x. 11 wildfly wildfly 239 Jun 16 18:09 wildfly-preview-24.0.0.Final
-rw-r--r--. 1 root root 207638148 Jun 16 21:17 wildfly-preview-24.0.0.Final.tar.gz

Déplacez le contenu du répertoire wildfly-preview-24.0.0.Final au /opt/wildfly :

Configure systemd for Wildfly :

We will now create a user and a group to start the Wildfly service :

[root@server ~]# groupadd --system wildfly
[root@server ~]# useradd -s /sbin/nologin --system -d /opt/wildfly -g wildfly wildfly

Create the Wildfly configuration directory :

[root@server ~]# mkdir /etc/wildfly

Copy the Wildfly systemd, configuration and script file :

[root@server ~]# cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
[root@server ~]# cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
[root@server ~]# cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/

Change the owner of /etc/wildfly :

[root@server ~]# chown -R wildfly:wildfly /opt/wildfly

Restart the systemd service :

[root@server ~]# systemctl daemon-reload

SElinux Configuration :

[root@server ~]# semanage fcontext -a -t bin_t "/opt/wildfly/bin(/.*)?"
[root@server ~]# restorecon -Rv /opt/wildfly/bin/

Start and enable the Wildfly service :

[root@server ~]# systemctl start wildfly
[root@server ~]# systemctl enable wildfly
[root@server ~]# systemctl status wildfly
● wildfly.service - The WildFly Application Server
Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-09-02 13:51:17 EDT; 10min ago
Main PID: 2837 (launch.sh)
CGroup: /system.slice/wildfly.service
├─2837 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
├─2838 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
└─2921 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modu…
Sep 02 13:51:17 server.stng.com systemd[1]: Started The WildFly Application Server.

Check if 8080 port is open with the netstat command :

[root@server ~]# netstat -tunelp | grep 8080
tcp       0      0 0.0.0.0:8080      0.0.0.0:*       LISTEN    996    32767     2921/java

Or with the ss command :

[root@server ~]# ss -tunelp | grep 8080
tcp        LISTEN       0       128       *:8080         *:*        users:(("java",pid=2921,fd=500)) uid:996 ino:32767 sk:ffff946834351740 <->

Add a Wildfly user :

Now we will create a Wildfly user who can access the administration console or remotely from the CLI, to do that, run the script below :

[root@server ~]# /opt/wildfly/bin/add-user.sh
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a):

The script asks you what type of user do you want to add, choose « a » since this is our first user.

Then enter in the username and password and answer « yes » for the following questions :

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : sysreseau
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 :
Re-enter Password :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]:
About to add user 'sysreseau' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'sysreseau' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'sysreseau' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'sysreseau' with groups to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'sysreseau' 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 Jakarta Enterprise Beans calls.
yes/no? yes
To represent the user add the following to the server-identities definition

Access to the Wildfly administration console :

To can access the Wildfly script directly add the path « /opt/wildfly/bin/ » to the value $PATH :

[root@server ~]# cat >> ~/.bashrc <<EOF
export WildFly_BIN="/opt/wildfly/bin/"
export PATH=\$PATH:\$WildFly_BIN
EOF

Connectez-vous avec la commande ci-dessous :

Login with the command below :

[root@server ~]# jboss-cli.sh --connect
[standalone@localhost:9990 /]

Access the Wildfly administration console with the web interface :

By default, the console is only accessible from the localhost on port 9990 :

[root@server ~]# ss -tunelp | grep 9990
tcp         LISTEN       0       50      127.0.0.1:9990        users:(("java",pid=2921,fd=493)) uid:996 ino:32770 sk:ffff946834353640 <

Edit the /opt/wildfly/bin/launch.sh file :

[root@server ~]# vim /opt/wildfly/bin/launch.sh
#!/bin/bash

if [ "x$WILDFLY_HOME" = "x" ]; then
WILDFLY_HOME="/opt/wildfly"
fi
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

Add « -bmanagement = 0.0.0.0 » as mentioned above :

Then restart the Wildfly service :

[root@server ~]# systemctl restart wildfly
[root@server ~]# ss -tunelp | grep 9990
tcp       LISTEN       0       50        *:9990       *:*        users:(("java",pid=3382,fd=404)) uid:996 ino:46018 sk:ffff946834350f80 <->

As you can see, the console is now listening on all ports :

Open port 9990 and 8080 on the firewall:

[root@server ~]# firewall-cmd --permanent --add-port={8080,9990}/tcp
[root@server ~]# firewall-cmd --reload

Open your browser and type the server’s IP address and port 9990, then type your login and password created previously :

wildfly

And here is your Wildfly is well installed and our beautiful console is easily accessible.

You might also like

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *