Are you looking to deploy Java applications on a robust, enterprise-grade application server? WildFly (formerly known as JBoss AS) is one of the most popular choices for developers and system administrators worldwide. In this comprehensive guide, we’ll walk you through every step of installing WildFly on Ubuntu, from initial system preparation to advanced configuration.
Whether you’re a seasoned developer or just starting your journey with Java application servers, this guide will provide you with all the knowledge you need to get WildFly up and running smoothly on your Ubuntu system.
What is WildFly and Why Use It?
WildFly is a flexible, lightweight, and managed application server that implements the latest enterprise Java specifications. Originally developed by Red Hat, it’s now maintained as an open-source project that powers countless enterprise applications across the globe.
Key Features of WildFly
WildFly stands out in the crowded application server market for several compelling reasons:
Lightning-Fast Boot Time: WildFly can start up in as little as 3 seconds, making it incredibly efficient for development and production environments. This quick startup time translates to faster deployment cycles and reduced downtime during updates.
Memory Efficiency: Unlike heavyweight alternatives, WildFly uses minimal memory footprint while maintaining full Java EE capabilities. A typical WildFly installation can run comfortably with just 64MB of heap space for simple applications.
Modular Architecture: The server uses a sophisticated modular classloading system that only loads what you need, reducing memory consumption and improving security by minimizing the attack surface.
Hot Deployment: You can deploy and undeploy applications without restarting the server, which is crucial for maintaining high availability in production environments.
WildFly vs Other Application Servers
When compared to other popular application servers like Apache Tomcat or Oracle WebLogic, WildFly offers a sweet spot between functionality and resource consumption. While Tomcat is lighter but lacks full Java EE support, and WebLogic provides enterprise features but at a significant resource cost, WildFly delivers comprehensive Java EE compliance without the overhead.
Prerequisites for Installing WildFly on Ubuntu
Before diving into the installation process, let’s ensure your system meets all the necessary requirements.
System Requirements
Your Ubuntu system should meet these minimum specifications:
- Ubuntu Version: 18.04 LTS or newer (22.04 LTS and 24.04 LTS recommended)
- RAM: Minimum 1GB (4GB recommended for production)
- Disk Space: At least 2GB free space
- CPU: Any modern x64 processor
- Network: Internet connection for downloading packages
Java Installation Requirements
WildFly requires Java to run, and the version you choose can significantly impact performance and compatibility.
Supported Java Versions:
- Java 8 (minimum requirement)
- Java 11 (recommended for long-term support)
- Java 17 (latest LTS version, best performance)
Checking Your Java Version
Before proceeding, let’s check if Java is already installed on your system:
java -version
javac -version
If Java isn’t installed or you’re running an outdated version, don’t worry – we’ll install the correct version in the next section.
Preparing Your Ubuntu System
Proper system preparation is crucial for a smooth WildFly installation. Let’s start by ensuring your Ubuntu system is up to date.
Updating Ubuntu Packages
First, update your package manager’s cache and upgrade existing packages:
sudo apt update
sudo apt upgrade -y
This process might take a few minutes depending on your internet connection and the number of packages that need updating.
Installing Java Development Kit (JDK)
WildFly requires a full JDK installation, not just the Java Runtime Environment (JRE). Here’s how to install OpenJDK 11, which offers the best balance of stability and performance:
sudo apt install openjdk-11-jdk -y
For those who prefer Oracle JDK or need Java 17, you can add the appropriate repositories:
# For Java 17
sudo apt install openjdk-17-jdk -y
Verify the installation:
java -version
javac -version
You should see output indicating Java 11 or 17 is installed correctly.
Setting Up JAVA_HOME Environment Variable
WildFly needs to know where Java is installed. Set the JAVA_HOME environment variable:
echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' >> ~/.bashrc
source ~/.bashrc
Verify the JAVA_HOME setting:
echo $JAVA_HOME
Downloading WildFly
Now that your system is prepared, let’s download the latest version of WildFly.
Finding the Latest WildFly Version
WildFly releases follow a regular schedule, with new versions typically released every quarter. As of 2024, WildFly 30+ versions are available, each bringing performance improvements and new features.
Download Methods
You have several options for downloading WildFly:
Using wget Command
The command-line method is fastest and most suitable for server environments:
cd /tmp
wget https://github.com/wildfly/wildfly/releases/download/37.0.1.Final/wildfly-37.0.1.Final.tar.gz
Manual Download Alternative
If you prefer a graphical approach, you can visit the WildFly website and download the latest stable release directly to your Downloads folder.
Installing WildFly on Ubuntu
With WildFly downloaded, let’s proceed with the actual installation.
Extracting the WildFly Archive
Extract the downloaded archive:
tar -xzf wildfly-37.0.1.Final.tar.gz
This creates a directory named
containing all WildFly files.wildfly-37.0.1
.Final
Moving WildFly to the Optimal Directory
For better organization and security, move WildFly to /opt
:
sudo mv wildfly-37.0.1.Final /opt/wildfly
This location is standard for third-party applications on Linux systems and makes it easier to manage permissions and access.
Setting Up WildFly User and Permissions
Running WildFly as root is a security risk. Create a dedicated user:
sudo useradd -r -g daemon -s /bin/false -d /opt/wildfly wildfly
Set appropriate ownership:
sudo chown -R wildfly:daemon /opt/wildfly
sudo chmod -R 755 /opt/wildfly
These permissions ensure WildFly can read and execute its files while maintaining security.
Configuring WildFly
Proper configuration is essential for optimal WildFly performance and security.
Basic WildFly Configuration
WildFly’s main configuration files are located in /opt/wildfly/standalone/configuration/
. The primary file is standalone.xml
, which controls most server behavior.
Setting Up Environment Variables
Create environment variables that WildFly scripts can use:
echo 'export WILDFLY_HOME=/opt/wildfly' >> ~/.bashrc
echo 'export WILDFLY_USER=wildfly' >> ~/.bashrc
source ~/.bashrc
Creating WildFly Service Script
Create a systemd service file for easier management:
sudo nano /etc/systemd/system/wildfly.service
Add the following content:
[Unit]
Description=WildFly Application Server
After=network.target
[Service]
Type=notify
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
Group=daemon
ExecStart=/opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
StandardOutput=null
TimeoutStartSec=600
TimeoutStopSec=600
[Install]
WantedBy=multi-user.target
Starting and Managing WildFly Service
Let’s get WildFly running and ensure it starts automatically.
Starting WildFly for the First Time
Enable and start the WildFly service:
sudo systemctl daemon-reload
sudo systemctl enable wildfly
sudo systemctl start wildfly
Check the service status:
sudo systemctl status wildfly
You should see output indicating that WildFly is active and running.
Creating Systemd Service
The systemd integration we created above provides several benefits:
- Automatic startup: WildFly starts automatically when the system boots
- Process management: systemd monitors WildFly and can restart it if it crashes
- Logging integration: Logs are automatically captured and managed by systemd
Enabling Auto-Start on Boot
With the service enabled, WildFly will automatically start when your Ubuntu system boots. You can verify this by rebooting and checking the service status.
Accessing WildFly Management Console
WildFly provides a powerful web-based management console for administration tasks.
Creating Management User
Before accessing the console, create an administrative user:
sudo -u wildfly /opt/wildfly/bin/add-user.sh
Follow the prompts to create a management user. Choose a strong password and remember these credentials – you’ll need them to access the admin interface.
Accessing the Admin Interface
Open your web browser and navigate to:
- Application:
http://your-server-ip:8080
- Management Console:
http://your-server-ip:9990
The default WildFly welcome page should appear at port 8080, while the management console is available at port 9990.
Troubleshooting Console Access
If you can’t access the console, check these common issues:
- Firewall blocking: Ensure ports 8080 and 9990 are open
- Binding address: WildFly might only be listening on localhost
- Service status: Verify WildFly is running with
systemctl status wildfly
Security Configuration
Security should be a top priority when deploying any application server.
Firewall Configuration
Configure Ubuntu’s firewall (UFW) to allow WildFly traffic:
sudo ufw allow 8080/tcp
sudo ufw allow 9990/tcp
sudo ufw enable
For production environments, consider restricting management console access to specific IP addresses.
SSL/HTTPS Setup
For production deployments, enable SSL encryption:
- Generate or obtain SSL certificates
- Configure WildFly’s SSL/TLS settings in
standalone.xml
- Update firewall rules to allow HTTPS (port 8443)
Basic Security Hardening
Additional security measures include:
- Regular updates: Keep WildFly and Java updated
- User permissions: Limit file system access for the wildfly user
- Network segmentation: Use firewalls to isolate WildFly from unnecessary network traffic
- Monitoring: Implement logging and monitoring solutions
Testing Your WildFly Installation
Let’s verify that everything is working correctly.
Deploying a Sample Application
WildFly comes with sample applications you can use for testing:
cd /opt/wildfly/standalone/deployments
sudo -u wildfly cp /opt/wildfly/docs/examples/simple-webapp.war .
The application should auto-deploy within seconds. Check the deployment status in the management console or server logs.
Performance Testing
For production environments, conduct thorough performance testing:
- Load testing: Use tools like Apache JMeter or Gatling
- Memory monitoring: Watch memory usage patterns
- Response time analysis: Measure application response times under load
Common Issues and Troubleshooting
Even with careful installation, you might encounter some challenges.
Port Conflicts
If ports 8080 or 9990 are already in use, you’ll need to change WildFly’s configuration:
- Edit
/opt/wildfly/standalone/configuration/standalone.xml
- Find the socket-binding-group section
- Change port numbers as needed
- Restart WildFly
Memory Issues
WildFly might run out of memory under heavy load. Increase heap size by modifying the startup script:
sudo nano /opt/wildfly/bin/standalone.conf
Add or modify:
JAVA_OPTS="-Xms1024m -Xmx2048m"
Permission Problems
If WildFly can’t read configuration files or write logs, check file permissions:
sudo chown -R wildfly:daemon /opt/wildfly
sudo chmod -R 755 /opt/wildfly
WildFly Maintenance and Updates
Keeping WildFly updated and well-maintained ensures optimal performance and security.
Regular Maintenance Tasks
Establish a maintenance routine that includes:
- Log rotation: Prevent log files from consuming excessive disk space
- Performance monitoring: Track memory usage, response times, and error rates
- Backup procedures: Regularly backup configuration files and deployed applications
- Security patches: Apply Java and system security updates promptly
Updating WildFly
When new WildFly versions are released:
- Backup current installation: Always backup before upgrading
- Test in staging: Never upgrade production directly
- Migration considerations: Review release notes for breaking changes
- Rollback plan: Have a rollback strategy ready
The update process typically involves downloading the new version, stopping the service, replacing files, and starting the service again.
Frequently Asked Questions (FAQs)
Q1: Can I install multiple versions of WildFly on the same Ubuntu server?
Yes, you can install multiple WildFly versions by extracting them to different directories (like /opt/wildfly-28
and /opt/wildfly-30
) and configuring them to use different ports. Each instance needs its own systemd service file with unique port configurations to avoid conflicts.
Q2: What’s the difference between standalone and domain mode in WildFly?
Standalone mode runs a single WildFly instance, perfect for development or single-server deployments. Domain mode allows you to manage multiple WildFly instances across different servers from a central domain controller, making it ideal for large-scale enterprise deployments with load balancing and centralized configuration management.
Q3: How much memory should I allocate to WildFly in production?
Memory allocation depends on your application requirements, but a good starting point is 2-4GB for most applications. Monitor your application’s memory usage and adjust accordingly. Use profiling tools to identify optimal heap sizes, and always leave some system memory available for the operating system.
Q4: Can I run WildFly behind a reverse proxy like Nginx or Apache?
Absolutely! Running WildFly behind a reverse proxy is a common production setup. The proxy can handle SSL termination, static content serving, and load balancing. Configure your proxy to forward requests to WildFly’s HTTP port (default 8080) and ensure proper headers are passed for session management.
Q5: How do I backup and restore my WildFly configuration and deployments?
Create regular backups of the /opt/wildfly/standalone
directory, which contains configurations, deployments, and data. For automated backups, use scripts that stop WildFly, copy the directory, and restart the service. Store backups in a separate location and test restore procedures regularly to ensure they work when needed.