3

How To Install WildFly on Rocky Linux 8|AlmaLinux 8

 2 years ago
source link: https://computingforgeeks.com/how-to-install-wildfly-on-rocky-almalinux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
How To Install WildFly on Rocky Linux 8|AlmaLinux 8

WildFly, initially known as JBoss Application Server is an exceptionally fast and lightweight open-source implementation of the JEE (Java Enterprise Edition) container. WildFly is written in Java was developed by RedHat to help manage application runtime and build apps. This tool was developed in 2006 by JBoss Inc and later acquired by RedHat to become the WildFly. The name was changed due to the confusion brought in the portfolio by the product names. WildFly can be run on several Operating systems with support for both 32 and 64-bit.

The latest release WildFly 26 comes with a lot of features and improvements. The amazing features associated with WildFly are:

  • Lightweight – WildFly takes an aggressive approach to memory management. The base runtime services were developed to minimize heap allocation by using common cached indexed metadata over duplicate full parses, which reduces heap and object churn.
  • Standard based – WildFly implements the latest in enterprise Java standards from Jakarta EE and Eclipse MicroProfile. These improve developer productivity by providing rich enterprise capabilities in easy to consume frameworks that eliminate boilerplate and reduce technical burden.
  • Modular – WildFly does classloading right. It uses JBoss Modules to provide true application isolation, hiding server implementation classes from the application and only linking with JARs your application needs.
  • Powerful – The configuration in WildFly is centralized, simple and user-focused. The configuration file is organized by subsystems that you can easily comprehend and no internal server wiring is exposed.

This guide aims to demonstrate how to install the latest version of WildFly on Rocky Linux 8 | AlmaLinux 8.

Getting Started.

For this guide, you need the following:

  • Rocky Linux 8 | AlmaLinux 8 system.
  • Memory above 2GB RAM

Also, ensure that packages on your system are updated to their latest available versions.

sudo yum update

Now use the below steps to install WildFly on Rocky Linux 8 | AlmaLinux 8

Step 1 – Install Java on Rocky Linux 8 | AlmaLinux 8

Since WildFly is built on Java, we need to have Java installed before we proceed. For this guide, we will install Java OpenJDK 11.

sudo yum install java-11-openjdk-devel

Once installed, verify the Java version.

$ java -version
openjdk version "11.0.14.1" 2022-02-08 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.14.1+1-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.14.1+1-LTS, mixed mode, sharing)

Step 2 – Install WildFly on Rocky Linux 8|AlmaLinux 8

Before we download and install WildFly, we need to create a system user and group for WildFly. Create the user with a custom home directory as below.

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

Now proceed and download the latest release version of WildFly from the official WildFly website. For this guide, we will download the Jarkata EE Full & Web Distribution(26.0.1) TGZ file using Wget as below.

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

Once downloaded, extract the file to the /opt directory.

sudo tar xf wildfly-*.Final.tar.gz -C /opt/

Now we will create a symbolic link for WildFly, this is essential when upgrading or installing a different version on WildFly

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

Set the ownership of the file to the created Wildfly user.

sudo chown -RH wildfly:wildfly /opt/wildfly

Step 3 – Create Systemd service for WildFly

We will begin by creating the WildFly configurations in the /etc directory as below.

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

View the content of the configuration.

$ cat /etc/wildfly/wildfly.conf
# The configuration you want to run
WILDFLY_CONFIG=standalone.xml

# The mode you want to run
WILDFLY_MODE=standalone

# The address to bind to
WILDFLY_BIND=0.0.0.0

From the output above, we can agree that WildFly runs in Standalone mode by default, but you can still customize as per your preference.

Next copy the launch.sh script which is required to start WildFly as a service.

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

Now copy the service file for WildFly.

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

You also need a directory to hold the PIDfile

sudo mkdir /var/run/wildfly/
sudo chown -R wildfly:wildfly /var/run/wildfly/

Now start and enable WildFly on Rocky Linux 8 | AlmaLinux 8.

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

Check the status of the service.

$ systemctl status wildfly.service
● wildfly.service - The WildFly Application Server
   Loaded: loaded (/usr/lib/systemd/system/wildfly.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-03-17 06:39:27 EDT; 20s ago
 Main PID: 37572 (launch.sh)
    Tasks: 125 (limit: 36438)
   Memory: 273.6M
   CGroup: /system.slice/wildfly.service
           ├─37572 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
           ├─37573 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
           └─37666 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djbo>

Mar 17 06:39:27 localhost.localdomain systemd[1]: Started The WildFly Application Server.

Configure the firewall to allow the WildFly port through it.

sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

At this point, WildFly should be accessible on port 8080.

Step 4 – Configure WildFly Admin Console for Remote Access

By default, the WildFly admin console runs on localhost. In case we want to access it via a remote host, we need to make some configurations.

Fists we need to create an admin user to enable us to log in to the WildFly Admin Console.

$ sudo /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): a

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : klinsmann
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 'klinsmann' for realm 'ManagementRealm'
Is this correct yes/no? yes
....
Added user 'klinsmann' with groups  to file '/opt/wildfly-26.0.1.Final/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 <secret value="UGFzc3cwcmQh" />

Next, we will create an environment variable for WildFly.

$ sudo vi /etc/wildfly/wildfly.conf

# The address to bind console to
WILDFLY_CONSOLE_BIND=0.0.0.0

Also, edit the launch.sh script.

$ sudo vi /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 -bmanagement $4
else
    $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4
fi

Edit the WildFly service file as well.

sudo vi /usr/lib/systemd/system/wildfly.service

Edit the file as below:

[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service

[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND
StandardOutput=null

[Install]
WantedBy=multi-user.target

Reload the system daemon and restart the WildFly service.

sudo systemctl daemon-reload
sudo systemctl restart wildfly.service

Now allow the WildFly Administration Console port through the firewall.

sudo firewall-cmd --permanent --add-port=9990/tcp
sudo firewall-cmd --reload

Disable SELinux.

sudo setenforce 0

Step 5 – Access the WildFly Admin Console

Now proceed and access the WildFly Admin Console using the URL http://IP_address:9990/console.

Provide the created admin user credentials.

Now we will deploy a sample Java application on the WildFly server. First, download the Helloworld Java Application from GitHub as below.

cd /opt/wildfly/standalone/deployments/
sudo curl -O https://raw.githubusercontent.com/aeimer/java-example-helloworld-war/master/dist/helloworld.war

View the files available.

$ ls
helloworld.war  helloworld.war.deployed  README.txt

From the output above, the file named *.deployed shows that the application has been deployed successfully, otherwise the file will be named *.failed. You can WildFly view logs as below.

$ tail /opt/wildfly/standalone/log/server.log  | grep helloworld
2022-03-17 07:07:07,674 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "helloworld.war" (runtime-name: "helloworld.war")
2022-03-17 07:07:08,818 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 81) WFLYUT0021: Registered web context: '/helloworld' for server 'default-server'
2022-03-17 07:07:08,886 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "helloworld.war" (runtime-name : "helloworld.war")

The deployment can be viewed on the browser using the URL http://IP_address:8080/helloworld/

Voila!

That marks the end of this guide. We have successfully set up WildFly server on Rocky Linux 8 | AlmaLinux 8 and also deployed a sample application. Now proceed and use WildFly to build and manage applications.

Related posts:


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK