25.2 C
Texas
angeloma
Senior Writer and partner

Install Wildfly (JBoss) on Debian 10

Hello, friends. This post will be really useful if you consider yourself a JavaEE developer. In this post, you will learn how to install Wildfly (JBoss) on Debian 10. This way you will have an application server that you can use for deploying Java applications.

According to the Wildfly website:

WildFly is a flexible, lightweight, managed application runtime that helps you build amazing applications.

Being Java-based, it is compatible with many operating systems such as Linux, macOS, and Windows. In addition to this, it is open source which can help us with licensing issues.

So, now you will learn how to install it on a Debian 10 server or your computer for development.

Install Wildfly on Debian 10

- Advertisement -

Before we start, open a terminal and update Debian 10. In this post, we will use sudo if you don’t know how to enable it in Debian, we tell you in this post.

sudo apt update
sudo apt upgrade

Now it is time to install Java if you don’t have it on your system.

sudo apt install default-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java default-jdk-headless default-jre default-jre-headless fontconfig-config fonts-dejavu-core java-common libasound2 libasound2-data
  libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libfontconfig1
  libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libharfbuzz0b libjpeg62-turbo liblcms2-2 libllvm7 libnspr4 libnss3
  libpciaccess0 libpcsclite1 libsensors-config libsensors5 libx11-6 libx11-data libx11-xcb1 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0
  libxcb-sync1 libxcb1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-11-jdk openjdk-11-jdk-headless
  openjdk-11-jre openjdk-11-jre-headless x11-common
Suggested packages:
  libasound2-plugins alsa-utils cups-common liblcms2-utils pciutils pcscd lm-sensors openjdk-11-demo openjdk-11-source visualvm libnss-mdns fonts-dejavu-extra
  fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
Recommended packages:
  libxt-dev libatk-wrapper-java-jni fonts-dejavu-extra
The following NEW packages will be installed:
  ca-certificates-java default-jdk default-jdk-headless default-jre default-jre-headless fontconfig-config fonts-dejavu-core java-common libasound2 libasound2-data
  libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libfontconfig1
  libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libharfbuzz0b libjpeg62-turbo liblcms2-2 libllvm7 libnspr4 libnss3
  libpciaccess0 libpcsclite1 libsensors-config libsensors5 libx11-6 libx11-data libx11-xcb1 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0
  libxcb-sync1 libxcb1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 openjdk-11-jdk openjdk-11-jdk-headless
  openjdk-11-jre openjdk-11-jre-headless x11-common
0 upgraded, 63 newly installed, 0 to remove and 26 not upgraded.
Need to get 289 MB of archives.
After this operation, 637 MB of additional disk space will be used.
Do you want to continue? [Y/n]

It is recommended to create a new user and group for Wildfly so that it does not interfere with the others. First, create a group like this

sudo groupadd -r wildfly

Now create the user:

sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly

From the previous command, we can deduce that you will not be able to log in but you will have permission over the directory /opt/wildfly.

Now yes, from the /tmp folder, you can download Wildlfly

cd /tmp/
wget -c https://download.jboss.org/wildfly/24.0.0.Final/wildfly-24.0.0.Final.tar.gz
--2021-07-13 16:47:17--  https://download.jboss.org/wildfly/24.0.0.Final/wildfly-24.0.0.Final.tar.gz
Resolving download.jboss.org (download.jboss.org)... 2a02:26f0:6c00::210:bb8b, 2a02:26f0:6c00::210:bb58, 104.126.36.121, ...
Connecting to download.jboss.org (download.jboss.org)|2a02:26f0:6c00::210:bb8b|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 210418338 (201M) [application/x-gzip]
Saving to: ‘wildfly-24.0.0.Final.tar.gz’

wildfly-24.0.0.Final.tar.gz               100%[=====================================================================================>] 200.67M  40.7MB/s    in 4.8s

2021-07-13 16:47:22 (42.0 MB/s) - ‘wildfly-24.0.0.Final.tar.gz’ saved [210418338/210418338]

At the time of writing this post, the latest stable version of Wildfly is 24.0.0 so this command will change when a new version is released.

Then, decompress it

sudo tar xfv wildfly-24.0.0.Final.tar.gz -C /opt/

Make a symbolic link from the folder to another folder with an easier-to-remember name.

sudo ln -s /opt/wildfly-24.0.0.Final/ /opt/wildfly

Make the user wildfly the owner of the folder.

sudo chown -RH wildfly: /opt/wildfly

Configuring WildFly on Debian 10

By default, the package we have downloaded includes a configuration file that we have to enable. To do this, create a folder called wildfly in the /etc/ path.

sudo mkdir -p /etc/wildfly

And to enable the default Wildfly configuration, copy the example file to this directory.

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/

Also, copy the startup script into the bin folder of the dedicated Wildfly folder.

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/systemd/launch.sh /opt/wildfly/bin/

After this, assign run permissions to the script.

sudo sh -c 'chmod +x /opt/wildfly/bin/*.sh'

To start, restart and stop running Wildfly then it is best to do it via systemd, and then we have to create a new service for it. Fortunately, the downloaded package includes one so we have to copy it to the directory where the service configurations are hosted.

sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

Now, refresh the list of services

sudo systemctl daemon-reload

And start the service

sudo systemctl start wildfly

Also, you can check the service for any errors.

sudo systemctl status wildfly
● wildfly.service - The WildFly Application Server
   Loaded: loaded (/etc/systemd/system/wildfly.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-07-13 16:52:28 CEST; 2s ago
 Main PID: 4978 (launch.sh)
    Tasks: 69 (limit: 4915)
   Memory: 196.4M
   CGroup: /system.slice/wildfly.service
           ├─4978 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
           ├─4979 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
           └─5074 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkJul 13 16:52:28 osradar systemd[1]: Started The WildFly Application Server.

All that remains is to create the user with administrative permissions. To do this, run a script called add-user.sh.

After entering the username, and answering a few more questions, you will be assigned a password.

To represent the user add the following to the server-identities definition <secret value="YW5nZWxv" />
1.- Creating a new user for Wildfly
1.- Creating a new user for Wildfly

This way, you can open your web browser and visit http://localhost:8080 or if you installed on a server http://your-server:8080 and see this screen.

2.- Wildfly running on Debian 10
2.- Wildfly running on Debian 10

So, Wildfly is correctly installed.

Optional: Enable the administrative panel remotely

The administrative panel can be accessed from http://localhost:9990/console but if you installed Wildfly on a remote server, this will not work because, by default, this feature is disabled remotely.

So, you can enable it. To do this, edit the Wildfly configuration file

sudo nano /etc/wildfly/wildfly.conf

And add the following line at the end.

WILDFLY_CONSOLE_BIND=0.0.0.0.0

Save the changes and close the editor.

Now edit the WildFly startup script

sudo nano /opt/wildfly/bin/launch.sh

And replace the lines inside the second if that start with $WILDFLY_HOME with the following lines

$WILDFLY_HOME/bin/domain.sh -c $2 -b $3 -bmanagement $4
else
$WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4

Save the changes and close the editor.

After this, you need to modify something in the file that manages the Wildfly service.

sudo nano /etc/systemd/system/wildfly.service

Change the ExecStart line to this one

ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND $WILDFLY_CONSOLE_BIND

Refresh all daemons and restart the service.

sudo systemctl daemon-reload
sudo systemctl restart wildfly

You will now be able to remotely access your configuration panel.

Conclusion

Developing Java applications requires tools to help with the process. In this case, we have presented you with one that allows you to set up a JavaEE application server, and with Wildfly’s extensive experience we will have mature and production-ready software.

Enjoy it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article