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.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our customers to perform related Java applications installation queries.
In this context, we shall look into how to install WildFly on Ubuntu 20.04.
1. Perform System Update
It is important to ensure your system packages are up to date. Run the following commands:
$ sudo apt upgrade
$ sudo apt update
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
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
4. Download and Install Wildfly
Now, 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:
$ 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
5. Configure Systemd for Wildfly
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. Execute the below command:
$ 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:
$ sudo sh -c 'chmod +x /opt/wildfly/bi n/*.sh'
Finally, copy Wildfly systemd file to the /etc/systemd/system/ directory:
$ 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
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:
$ sudo nano /etc/wildfly/wildfly.conf
Then, Append the line below to the file:
WILDFLY_CONSOLE_BIND=0.0.0.0
Next, 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.
Now, open the launch script:
$ sudo nano /opt/wildfly/bin/launch.sh
Modify the lines below in the script:
$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 by running the below command:
$ 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 with the below commands:
$ 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 WildFly HAL Management Console dashboard.
Here, we will install and configure Nginx as a reverse proxy for the wildfly on the Ubuntu system.
Install Nginx packages using the apt command below:
$ sudo apt install nginx -y
Once all installation is finished, go to the '/etc/nginx/' configuration directory;
$ cd /etc/nginx/
Create a new file 'proxy_headers.conf' under the '/etc/nginx/conf.d' directory using vim editor:
$ vim conf.d/proxy_headers.conf
Paste the following configuration:
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
add_header Front-End-Https on;
add_header Cache-Control no-cache;
Save and close.
Next, create a new virtual host configuration for wildfly under the '/etc/nginx/sites-available' directory:
$ vim sites-available/wildfly
Change the IP address with your own and paste the configuration into it:
server {
listen 80;
server_name SERVER-IP;
location / {
include conf.d/proxy_headers.conf;
proxy_pass http://127.0.0.1:8080;
}
location /management {
include conf.d/proxy_headers.conf;
proxy_pass http://127.0.0.1:9990/management;
}
location /console {
include conf.d/proxy_headers.conf;
proxy_pass http://127.0.0.1:9990/console;
}
location /logout {
include conf.d/proxy_headers.conf;
proxy_pass http://127.0.0.1:9990/logout;
}
location /error {
include conf.d/proxy_headers.conf;
proxy_pass http://127.0.0.1:9990;
}
}
Save and close.
Next, activate the wildfly virtual host and check the Nginx configuration:
$ ln -s /etc/nginx/sites-available/wildfly /etc/nginx/sites-enabled/
$ nginx -t
Now make sure there is no error, then restart the Nginx service:
$ systemctl restart nginx
Finally, the Nginx installation and configuration s a reverse proxy for wildfly has been completed.
This article covers how to successfully install and configure WildFly on Ubuntu 20.04. Infact, WildFly offers you an administration dashboard to manage single or multiple domains efficiently.