Ubuntu

How to Install WildFly on Ubuntu 20.04

How to Install WildFly on Ubuntu 20.04

WildFly (formerly JBoss) is a lightweight, quick, and highly optimized application server that lets you build outstanding Java applications. WildFly is a cross-platform and comes with a sophisticated interface that makes changing application server settings and configuration very simple and quick.

It is currently maintained by RedHat as an open-source project and is also available for commercial enterprise environments

In this guide, we will discuss how to install WildFly on Ubuntu 20.04.

Step 1: Update your system

It is important to ensure your system packages are up to date. Run the following commands:

$ sudo apt upgrade
$ sudo apt update

Step 2: Install Java

Wildfly is software written in Java. We, therefore, need to install the Java environment on our Ubuntu 20.04 system

$ sudo apt install default-jdk

Step 3: Set up Wildfly User

We need to create a system user and group for Wildfly on the /opt/wildfy directory on our system. Run the following commands:

$ sudo groupadd -r wildfly
$sudo useradd -r -g wildfly /opt/wildfly -s /sbin/nologin wildfly

Step 4:Download and Install Wildfly

Next, download the Wildfly archive file from the official site. At the time of this writing, the latest version of Wildfly is 25.0.1. Run the following wget command to download the file to the /tmp directory

$ cd /tmp
$ wget wget https://github.com/wildfly/wildfly/releases/download/25.0.1.Final/wildfly-25.0.1.Final.tar.gz

Next, extract the downloaded archive file using the command:

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

Once complete, move the wildfly folder to the /opt directory as shown:

sudo mv wildfly-20.0.1.Final/ /opt/wildfly

Next, change the directory permissions to the user and group wildfly.

$ sudo chown -RH wildfly: /opt/wildfly

Step 4: Configure Systemd

Next, create a WildFly directory which will store the configuration files in the /etc/ directory. Execute the command:
$ sudo mkdir -p /etc/wildfly

Then copy the Wildfly configuration file to the folder created above. Run:

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

Next, run the following command to copy the launch.sh file to the /opt directory

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

Then, make the scripts in the /etc/wildfly/bin directory executable as shown:

$ sudo sh -c 'chmod +x /opt/wildfly/bi n/*.sh'

Finally, copy Wildfly systemd file to the /etc/systemd/system/ directory as shown below:

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

Now start and enable the Wildfly service on your machine. Run the commands;

$ sudo systemctl start wildfly.service
$ sudo systemctl enable wildfly.service

To verify Wildfly is up and running, execute the following command:

$ sudo systemctl status wildfly.service

Step 5: Configure Wildfly

Now that you have the Wildfly service running successfully on your machine, you need to create an admin user account to manage the web console. Run the console:

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

A prompt will appear. Type a and hit enter to proceed.

Next, create a new username and password.

Type yes for the rest of the options to proceed with the installation.

With the installation complete, fire up your browser and navigate to the address shown below to verify that WildFly is successfully installed on your local system.

http://localhost:8080

By default, the server console can only be accessed on localhost. To allow remote connections, edit the configuration files as shown:

$ sudo nano /etc/wildfly/wildfly.conf

Append the line below to the file:

WILDFLY_CONSOLE_BIND=0.0.0.0

Then, run the following script to create an account to login to the server console

$ sudo sh /opt/wildfly/bin/jboss-cli.sh --connect

You will be required to provide the username and password you created above.

Next, open the launch script

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

Modify the lines below in the script as shown below:

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

Close and save the file.

Now, restart the wildfly service for the changes to take effect. Run:

$ sudo systemctl restart wildfly.service

Next, open the systemd unit file and edit the line as shown by running the commands below.

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

Append the line $WILDFLY_CONSOLE_BIND to the line below

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

Save the file and exit.

Next, restart the systemd and the Wildfly service. Run:

$ sudo systemctl daemon-reload
$ sudo systemctl restart wildfly.service

You can now access the admin console on the address.

$ localhost:9900

You will be prompted to sign in.

After logging in successfully, you will be taken to the following dashboard:

Conclusion

You have successfully installed WildFly on Ubuntu 20.04.

Similar Posts