Linux Ubuntu

Install the Wildfly application server on Ubuntu 20.04 | 22.04 LTS

Tutorial to learn the commands to install the latest version of WildFly (JBoss) on Ubuntu 20.04 Focal Fossa or 22.04 Jammy Jelly Fish using its repository and terminal.

WildFly is a free open source application server written in Java that runs Java programs. The project emerged from the well-established Java application server but did not activate one – JBoss, a name used by Red Hat. Thus, WildFly is a successor to JBoss maintained by RedHat developers and the community.

Like its predecessor, the specification and compilation of Wildfly components, primarily for web services and communication, is not included in the Java SDK.

The concept of application server management is based on a generic and untyped management API. Regardless of the management interface used, all modifications are kept and versioned. All server management interfaces are secure by default. These include a CLI, web administration console, native Java API, HTTP / JSON REST API, and JMX gateway.

Steps to Install WildFly on Ubuntu 20.04 | 22.04

The steps shown here will be the same for Debian 10 Buster or 11 Bullseye, Ubuntu 20.04, Linux Mint, and other similar operating systems based on Debian.

1. Updating the Apt system

We need to install a few packages using APT package manager, so it would be good to run the system update command once if you haven’t done so for a while. This will rebuild the APT cache.

sudo apt update

2. Install OpenJDK 11 by default

The default Open Java version is available through Ubuntu 20.04 | The 22.04 repository is OpenJDK 11. Therefore, we are going for the same using the APT package manager command given below.

sudo apt install default-jdk

To confirm the Java version, you can use the given command:

java --version

3. Download WildFly on Ubuntu 20.04 | 22.04

Well, just like many other open source tool packages, WildFly is also not available through the default base package repository of Ubuntu 20.04 | 22.04. Therefore, we need to download its latest archive file available on the WildFly official site.

Go to the link then press the “Download LE TGZ”To get the archive file.

You can also right click on the button and select “Copy link address”. After that use it with wget order.

Example:

wget https://github.com/wildfly/wildfly/releases/download/26.0.0.Final/wildfly-26.0.0.Final.tar.gz

The downloaded file will contain the following:

Wildfly
Jakarta EE
Servlet distribution only
Application server source code
Source AL quick start source code
Release Notes

Now extract the archive that we downloaded in the previous step. Also, if you downloaded the WildFly through a browser, don’t forget to switch to the Downloads directory.

tar -xf wildfly-*.Final.tar.gz

To move to /opt directory, so that we don’t accidentally delete it.

sudo mv wildfly-*Final /opt/wildlfy

5. Creation of a dedicated WildFly user

To run the WildFly with a non-root user without sudo access, we create a separate user who will only have access to their files and folders.

Add group

sudo groupadd -r wildfly

Add a new user:

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

6. Change owner

The directory where we copied the extracted files is under /opt, gives its authorization to WildFly users.

sudo chown -RH wildfly:wildfly /opt/wildfly

7. Configure WildFly to install it on Ubuntu 22.04 | 04/20

Create the WildFly directory under / etc and copy some important configuration files like preconfigured service for Systemd to run the application server in the background of the system.

sudo mkdir -p /etc/wildfly

Copy the files:

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/

8. Make the script executable

Now let’s make some script files executable to make them work on our Ubuntu 20.04 | 22.04, required by WildFly to function properly.

Here are those:

add-user.sh, appclient.sh, common.sh, domain.sh, elytron-tool.sh, jboss-cli.sh, jconsole.sh, jdr.sh, launch.sh, standalone.sh, wsconsume.sh and wsprovide.sh.

sudo chmod +x /opt/wildfly/bin/*.sh

9. Start and activate the service

To have the WildFly application server run automatically with system startup; start and activate its service.

sudo systemctl enable --now wildfly
sudo systemctl daemon-reload

Check condition:

systemctl status wildfly

To stop or restart:

sudo systemctl restart wildfly
sudo systemctl stop wildfly

10. Create the WildFly management console and the application user

Then we run a script to either configure the “administrator”User or create a new one. Just run the given command:

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

11. Configure the Wildfly Admin Hal management console

By default, you will not be able to access the Administrator interface because as you do it, the system will give the following error:

Unable to redirect.

An automatic redirect to the Administration Console is not currently available. This is most likely due to the administration console being exposed over a network interface different from the one to which you are connected to.

To access the Administration console you should contact the administrator responsible for this WildFly installation and ask them to provide you with the correct address.

To remove this error and log into the management console on the system where you installed WildFly, edit its configuration file:

sudo nano /etc/wildfly/wildfly.conf

To replace 0.0.0.0 with 127.0.0.1 in the following line:

WILDFLY_BIND= 127.0.0.1

Restart the WildFly service:

sudo systemctl restart wildfly

Open port 8080 in the firewall:

If you are using a firewall, open the port:

sudo ufw allow 8080/tcp
sudo ufw allow 9090/tcp

Access the web interface, open your browser on the server or desktop where you installed this application server. And then point to-

http://127.0.0.1:8080

Click on the “Admin console“.

To access the Hal Management interface, you will first be asked to log in. Enter the user and password you created for the management interface.

12. Access WildFly remotely

If you want to access this application server running Ubuntu 20.04 | 22.04 servers. Then we need to make some changes first. Modify the standard configuration

Edit the configuration file:

sudo nano /opt/wildfly/standalone/configuration/standalone.xml

Scroll to the end of the file and find the Interfaces section and change the IP address of 127.0.0.1 at 0.0.0.0. After that save the file by pressing Ctrl + O, press the Enter, then Ctrl + X to leave. This will allow all machines that can access the server’s IP address to remotely access the WildFly web interface.

To note: For security reasons, if you want to link the public access of the management console to a particular trusted machine, then in the “Public”From the interface, link its address to the IP adress of the system through which you want to access it.



        


        

Now modify the front-end configuration file:

sudo nano /etc/wildfly/wildfly.conf

Again change the address to 0.0.0.0

Save the file.

Restart the server:

sudo systemctl restart wildfly

Once done, you can access your application server from any other computer by pointing to the IP address of the server where you are running the WildFly (Ubuntu).

Uninstall WildFly

To remove it completely, just delete the entries and folders we created to contain its files:

sudo rm -r /opt/wildlfy
sudo rm -r /etc/wildfly
sudo rm -r /etc/systemd/system/ wildfly.service 


Source link