Linux MintUbuntu Based

How To Install WildFly on Linux Mint 22

Install WildFly on Linux Mint 22

WildFly, formerly known as JBoss, has established itself as a powerful, modular, and lightweight Java application server that enables developers to build robust enterprise applications. If you’re running Linux Mint 22 and need a reliable Java EE application server, WildFly is an excellent choice that offers exceptional performance and flexibility. This comprehensive guide will walk you through the entire installation process, from preparing your system to deploying your first application.

Prerequisites

Before diving into the WildFly installation process, ensure your Linux Mint 22 system meets the necessary requirements. You’ll need at least 2GB of RAM (4GB recommended for production environments) and approximately 500MB of free disk space for the WildFly installation itself. Additional space will be needed for your applications and logs.

Your Linux Mint 22 system should have a stable internet connection for downloading packages. Basic command line knowledge is essential, as we’ll be working extensively with the terminal. You’ll also need root access or sudo privileges to install packages and configure system settings.

The entire installation process typically takes 30-45 minutes, depending on your system’s performance and internet speed. Having patience during the configuration steps will ensure a smooth installation experience.

Understanding WildFly

WildFly began its journey as JBoss Application Server before being rebranded in 2014. This open-source application server has evolved to become one of the most popular choices for deploying Java applications. The latest version offers significant improvements in terms of performance, security, and compliance with Java EE standards.

Key Features of WildFly

  • Modular architecture that reduces memory footprint
  • Full support for Jakarta EE specifications
  • Simplified configuration through a unified management interface
  • Clustering capabilities for high availability
  • Powerful deployment options
  • Integrated security framework
  • Quick startup time compared to other application servers

Unlike heavier alternatives such as WebLogic or WebSphere, WildFly maintains a balance between robust features and lightweight operation, making it ideal for both development and production environments on Linux Mint 22. Its architecture allows for selective loading of only the services you need, optimizing resource usage.

Preparing Your Linux Mint 22 System

Begin the installation process by ensuring your Linux Mint 22 system is up-to-date with the latest packages. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade

Next, install some essential utilities that will be needed throughout the installation process:

sudo apt install wget apt-transport-https gnupg2 software-properties-common unzip

These packages provide tools for downloading files, managing repositories, and extracting archives. Once installed, verify that your system has enough free disk space using the df -h command to ensure smooth operation of WildFly.

Installing Java Development Kit

WildFly requires a Java Development Kit (JDK) version 11 or higher to function properly. The latest versions of WildFly work best with OpenJDK 17, which we’ll install using the following command:

sudo apt install default-jdk

After installation completes, verify that Java is correctly installed by checking the version:

java --version

The output should display the installed Java version. Next, set up the JAVA_HOME environment variable, which WildFly will use to locate your Java installation:

echo 'export JAVA_HOME=/usr/lib/jvm/default-java' >> ~/.bashrc
source ~/.bashrc

To verify the JAVA_HOME variable is correctly set, run:

echo $JAVA_HOME

This should display the path to your Java installation. If you encounter any issues with Java, try installing a specific version of OpenJDK:

sudo apt install openjdk-17-jdk

Downloading WildFly

With Java installed, the next step is to download the latest stable release of WildFly. As of the writing of this article, the latest version is 26.1.3.Final. Use wget to download the archive:

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

After downloading, verify the integrity of the downloaded archive. While WildFly doesn’t officially provide checksum files, you can still check if the archive is not corrupted by trying to list its contents:

tar -tf wildfly-35.0.1.Final.tar.gz  > /dev/null

If this command completes without errors, the archive is likely intact. If you encounter download issues, you can alternatively visit the official WildFly website, navigate to the downloads section, and manually download the archive using your browser.

Creating a Dedicated WildFly User

For security reasons, it’s best practice to run WildFly under a dedicated system user rather than using your regular user account or root. This containment strategy limits potential security risks. Create a new user and group specifically for WildFly with the following commands:

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

These commands create a system user named “wildfly” belonging to the “wildfly” group. The user’s home directory is set to /opt/wildfly, and the shell is set to /sbin/nologin, which prevents direct login for this account—enhancing security.

Verify the user creation by checking the /etc/passwd file:

grep wildfly /etc/passwd

This step ensures that your WildFly server runs with only the necessary privileges, adhering to the principle of least privilege.

Installing WildFly

Now extract the WildFly archive and move the contents to the appropriate location:

tar -xf wildfly-35.0.1.Final.tar.gz
sudo mv wildfly-35.0.1.Final /opt/wildfly

After moving the files, set the correct ownership for all WildFly directories and files:

sudo chown -RH wildfly:wildfly /opt/wildfly

The WildFly directory structure includes several important directories:

  • bin: Contains scripts for starting, stopping, and managing the server
  • standalone: Configuration and deployment directories for standalone mode
  • domain: Configuration and deployment directories for domain mode
  • modules: Contains Java libraries and modules used by WildFly
  • docs: Documentation and examples

Familiarizing yourself with this structure will help you navigate and maintain your WildFly installation more effectively.

Configuring WildFly

To set up WildFly as a system service that starts automatically at boot time, we need to configure systemd. First, create the necessary configuration directories:

sudo mkdir -p /etc/wildfly

Next, copy the configuration files provided in the WildFly distribution:

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/

These files provide the necessary configurations for running WildFly as a systemd service. Open and examine the wildfly.conf file to understand its configuration options:

sudo nano /etc/wildfly/wildfly.conf

The default configuration should work for most cases, but you might want to modify certain parameters like the binding address or port numbers based on your specific requirements. For Linux Mint 22, the default configuration typically works well out of the box.

Make sure the launch script is executable:

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

Starting and Enabling WildFly Service

With the configuration in place, you can now start the WildFly service and enable it to start automatically at system boot:

sudo systemctl start wildfly
sudo systemctl enable wildfly

After starting the service, verify that it’s running properly:

sudo systemctl status wildfly

You should see output indicating that the service is active and running. If there are any issues, check the logs for error messages:

sudo journalctl -u wildfly

To properly restart or stop WildFly when needed, use the following commands:

sudo systemctl restart wildfly  # To restart
sudo systemctl stop wildfly     # To stop

These commands ensure that WildFly shuts down gracefully, preventing data corruption or incomplete operations.

Creating Management Users

WildFly’s administration console requires authenticated access, so you’ll need to create at least one administrative user. Use the add-user script provided by WildFly:

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

This interactive script will prompt you to:

  1. Select the type of user (choose ‘a’ for Management User)
  2. Enter a username
  3. Enter and confirm a password
  4. Provide optional details like groups and roles
  5. Confirm the information

For security, choose a strong password that includes a mix of uppercase and lowercase letters, numbers, and special characters. WildFly supports different user roles with varying levels of access, from read-only monitoring to full administrative control.

After creating the user, you can verify authentication by accessing the management console, which we’ll cover in a later section.

Configuring Firewall

For your WildFly applications to be accessible, you need to configure your firewall to allow traffic on the relevant ports. WildFly typically uses two main ports:

  • Port 8080 for HTTP requests to deployed applications
  • Port 9990 for the management console

If you’re using UFW (Uncomplicated Firewall), which is common on Linux Mint, open these ports with:

sudo ufw allow 8080/tcp
sudo ufw allow 9990/tcp

For additional services like HTTPS (8443) or AJP (8009), you’ll need to open those ports as well:

sudo ufw allow 8443/tcp  # For HTTPS
sudo ufw allow 8009/tcp  # For AJP

Verify your firewall configuration with:

sudo ufw status

In production environments, consider limiting access to the management port (9990) to specific IP addresses rather than exposing it publicly, enhancing your server’s security posture.

Accessing WildFly Remotely

By default, WildFly binds to 127.0.0.1, which means it’s only accessible from the local machine. To allow remote access, you need to modify the configuration:

  1. Edit the standalone.xml file:
sudo nano /opt/wildfly/standalone/configuration/standalone.xml
  1. Find the interfaces section and change the bind address:
<interfaces>
    <interface name="management">
        <inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
    </interface>
    <interface name="public">
        <inet-address value="${jboss.bind.address:0.0.0.0}"/>
    </interface>
</interfaces>
  1. Save the file and exit the editor.
  2. Also update the wildfly.conf file:
sudo nano /etc/wildfly/wildfly.conf
  1. Add or modify the following line:
WILDFLY_BIND=0.0.0.0
  1. Restart WildFly to apply the changes:
sudo systemctl restart wildfly

Be aware that exposing WildFly to remote connections increases security risks. Consider implementing additional security measures such as VPN access, SSL certificates, and robust authentication methods.

Testing Your WildFly Installation

To verify your WildFly installation is working correctly, open a web browser and navigate to:

http://localhost:8080

You should see the WildFly welcome page, indicating that the server is running successfully. To access the management console, navigate to:

http://localhost:9990/console

You’ll be prompted to enter the username and password you created earlier. After successful authentication, you’ll have access to the administrative interface where you can manage deployments, configure subsystems, view metrics, and more.

Install WildFly on Linux Mint 22

Explore the different sections of the management console to become familiar with the available options. The “Deployments” tab is particularly important, as it’s where you’ll deploy your Java applications.

Deploying Your First Application

To test the deployment functionality, let’s create a simple Java web application. For this example, we’ll use a pre-built WAR file. First, download a sample application:

wget https://github.com/wildfly/quickstart/releases/download/26.1.3.Final/helloworld.war

There are several ways to deploy this application:

  1. Using the Management Console:
    • Access the console at http://localhost:9990/console
    • Navigate to Deployments
    • Click on “Add” and select “Upload Deployment”
    • Choose the helloworld.war file and upload it
    • Enable the deployment when prompted
  2. Using the Command Line Interface:
    • Connect to the CLI:
    sudo /opt/wildfly/bin/jboss-cli.sh --connect
    • Deploy the application:
    deploy /path/to/helloworld.war
  3. Direct File Copy (not recommended for production):
    • Copy the WAR file to the deployments directory:
    sudo cp helloworld.war /opt/wildfly/standalone/deployments/

After deployment, access your application at:

http://localhost:8080/helloworld

If the application doesn’t appear, check the server logs for deployment errors:

sudo tail -f /opt/wildfly/standalone/log/server.log

Common deployment issues include class not found exceptions, conflicting dependencies, or permission problems, which can usually be resolved by examining the detailed error messages in the logs.

Performance Tuning

To optimize WildFly performance on Linux Mint 22, you can adjust various settings. The most important ones relate to memory allocation and JVM parameters. Edit the standalone.conf file:

sudo nano /opt/wildfly/bin/standalone.conf

Look for the JAVA_OPTS section and modify the memory settings based on your system’s available resources:

JAVA_OPTS="-Xms1024m -Xmx2048m -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=512m"

These settings allocate:

  • 1GB initial heap memory (-Xms1024m)
  • 2GB maximum heap memory (-Xmx2048m)
  • 512MB initial Metaspace (-XX:MetaspaceSize=512M)
  • 512MB maximum Metaspace (-XX:MaxMetaspaceSize=512m)

For systems with more RAM, you can increase these values. For better performance, consider additional JVM options:

JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC -XX:MaxGCPauseMillis=200"

These options enable the G1 garbage collector and set a target for maximum garbage collection pause time.

After making changes, restart WildFly:

sudo systemctl restart wildfly

Monitor your server’s performance using the management console’s metrics section, and adjust settings as needed based on actual usage patterns.

Backup and Maintenance

Regular backups are essential for any production WildFly installation. Implement a backup strategy that includes:

  1. Configuration files backup:
    sudo cp -r /opt/wildfly/standalone/configuration /backup/wildfly/
  2. Deployed applications backup:
    sudo cp -r /opt/wildfly/standalone/deployments /backup/wildfly/
  3. Database backups for applications that use databases

Schedule these backups using cron jobs for automation:

sudo crontab -e

Add a line like:

0 2 * * * tar -czf /backup/wildfly-$(date +\%Y\%m\%d).tar.gz /opt/wildfly/standalone/configuration /opt/wildfly/standalone/deployments

This creates a daily backup at 2 AM.

For log management, implement log rotation to prevent disk space issues:

sudo nano /etc/logrotate.d/wildfly

Add configuration:

/opt/wildfly/standalone/log/*.log {
    weekly
    rotate 12
    compress
    delaycompress
    missingok
    notifempty
    create 0640 wildfly wildfly
}

This rotates logs weekly, keeps 12 weeks of logs, and compresses older logs.

Troubleshooting Common Issues

When running WildFly on Linux Mint 22, you might encounter several common issues. Here’s how to address them:

Problem: WildFly fails to start

  • Check Java installation: java -version
  • Verify JAVA_HOME is correctly set: echo $JAVA_HOME
  • Check system logs: sudo journalctl -u wildfly
  • Ensure proper file permissions: sudo chown -R wildfly:wildfly /opt/wildfly
  • Check wildfly.conf for proper configuration

Problem: Port conflicts

  • Identify if ports are already in use:
    sudo netstat -tuln | grep 8080
    sudo netstat -tuln | grep 9990
  • Change WildFly ports in standalone.xml if needed

Problem: Memory issues

  • Increase Java heap size in standalone.conf
  • Check system memory availability: free -m
  • Monitor garbage collection: Add -verbose:gc to JAVA_OPTS

Problem: Permission denied errors

  • Check SELinux status: getenforce
  • Set appropriate file permissions
  • Ensure the wildfly user has access to necessary directories

If you encounter other issues, the WildFly community offers extensive support through:

  • Official documentation on wildfly.org
  • Community forums and mailing lists
  • Stack Overflow with the [wildfly] tag

Uninstalling WildFly

If you need to remove WildFly from your Linux Mint 22 system, follow these steps:

  1. Stop and disable the WildFly service:
    sudo systemctl stop wildfly
    sudo systemctl disable wildfly
  2. Remove WildFly files and directories:
    sudo rm -rf /opt/wildfly
    sudo rm -rf /etc/wildfly
    sudo rm /etc/systemd/system/wildfly.service
  3. Remove the WildFly user and group:
    sudo userdel wildfly
    sudo groupdel wildfly
  4. Reload systemd to apply changes:
    sudo systemctl daemon-reload

Verify the complete removal by checking that no WildFly processes are running:

ps aux | grep wildfly

This should return only the grep command itself, indicating no WildFly processes remain active.

Congratulations! You have successfully installed WildFly. Thanks for using this tutorial to install WildFly on Linux Mint 22. For additional help or useful information, we recommend you check the official WildFly website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button