[JAVA] How to install WildFly on Ubuntu 18.04

** WildFly ** is a free, open source, cross-platform application written in ** Java ** and developed by Red Hat.

Requirements

--A fresh Alibaba Cloud instance with the Ubuntu 18.04 desktop installed. --The instance has a root password.

Launch an Alibaba Cloud ECS instance

Create a new ECS instance (https://www.alibabacloud.com/help/ja/doc-detail/25424.htm), select Ubuntu 18.04 as the operating system with at least 4GB RAM, and as the root user Connect to your instance (https://www.alibabacloud.com/help/ja/doc-detail/25434.htm).

After logging in to your Ubuntu 18.04 desktop instance, run the following command to update your base system with the latest available packages.

apt-get update -y

Once your account is available, log in as a non-root user to get started.

Java installation

To use WildFly, Java version 8 must be installed on the server. By default, Java 8 is not available in the Ubuntu 18.04 default repository. Therefore, you need to download it from the company's official website.

After downloading Java 8, unzip it to the / usr / lib / jvm directory.

mkdir /usr/lib/jvm/
tar -zxvf jdk-8u221-linux-x64.tar.gz -C /usr/lib/jvm/

Then set the default version of Java with the following command:

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_221/bin/java 1

Next, verify Java with the following command.

java -version

output:

java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

Install WildFly

Before you can install WildFly, you need to create users and groups for WildFly. You can create it with the following command.

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

Then download the latest version of WildFly with the following command:

wget https://download.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.zip

After downloading, unzip the downloaded file and change to the / opt / wildfly directory with the following command.

unzip wildfly-17.0.1.Final.zip
mv wildfly-17.0.1.Final /opt/wildfly

Then give the Wildfly directory the appropriate permissions with the following command:

chown -RH wildfly: /opt/wildfly

Systemd file settings for WildFly

Copy the files needed to configure WildFly.

Then copy the WildFly config file to / etc / directory.

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

Then move the WildFly launch.sh file to the / opt / wildfly / bin / directory.

cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
sh -c 'chmod +x /opt/wildfly/bin/*.sh'

Then copy the WildFly systemd file with the following command:

cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

Reload the configuration file with the following command.

systemctl daemon-reload

Next, start the WildFly service so that it can be started at startup with the following command.

systemctl start wildfly
systemctl enable wildfly

You can now check the status of WildFly with the following command.

systemctl status wildfly

output:

● wildfly.service - The WildFly Application Server
   Loaded: loaded (/etc/systemd/system/wildfly.service; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-08-03 09:10:00 UTC; 7s ago
 Main PID: 15938 (launch.sh)
    Tasks: 52 (limit: 1098)
   CGroup: /system.slice/wildfly.service
           ├─15938 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
           ├─15943 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0
           └─16003 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true

Aug 03 09:10:00 hitesh systemd[1]: Started The WildFly Application Server.

WildFly authentication settings

Next, you need to create an admin user to access the WildFly admin console. You can add it with the following command.

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

You should see output similar to the following.

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 : letscloud
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 'letscloud' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'letscloud' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'letscloud' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'letscloud' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'letscloud' with groups  to file '/opt/wildfly/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 EJB calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="YWRtaW5AMTIz" />

WildFly settings for remote location access

By default, WildFly can only be accessed from localhost. Therefore, you need to configure WildFly for remote access. This can be done by editing the /etc/wildfly/wildfly.conf file.

nano /etc/wildfly/wildfly.conf

Add the following line.

WILDFLY_CONSOLE_BIND=0.0.0.0

Save and close the file. Then open the /opt/wildfly/bin/launch.sh file.

nano /opt/wildfly/bin/launch.sh

Modify the file as follows:

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

Save and close the file. Open the, /etc/systemd/system/wildfly.service file.

nano /etc/systemd/system/wildfly.service

Make the following changes.

[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

Save and close the file.

Then create the / var / run / wildfly directory and set the correct permissions.

mkdir /var/run/wildfly/
chown wildfly:wildfly /var/run/wildfly/

Finally, reload the systemd daemon and restart the service for the changes to take effect.

systemctl daemon-reload
systemctl restart wildfly

Access to the WildFly web console

Now open your web browser and enter the URL [http://your-server-ip:9990/console](http://your-server-ip:9990/console.?spm=a2c65. 11461447.0.0.40f92bacqqDcpb). You will be redirected to the next page.

image.png

Enter your username and password. Then click the Sign IN button. You should see WildFly's default dashboard on the following page.

image.png

Conclusion

Congratulations! WidFly is now installed and ready to use. WidFly is now installed and ready to use. Learn more: https://wildfly.org/

Thanks to Gary Stevens, CTO of Hosting Canada for helping us with this guide.

Recommended Posts

How to install WildFly on Ubuntu 18.04
How to install production Metabase on Ubuntu
How to install network drivers on standalone Ubuntu
How to install NVIDIA driver on Ubuntu 18.04 (Note)
How to install multiple JDKs on Ubuntu 18.04 LTS
How to install ImageMagick on Windows 10
How to install NVIDIA driver on Ubuntu ssh destination
How to use Bio-Formats on Ubuntu 20.04
How to install MariaDB 10.4 on CentOS 8
How to build vim on Ubuntu 20.04
How to install java9 on elementaryOS Freya or Ubuntu 14.04 LTS
How to install Eclipse (Photon) on Mac
I want to install PHP 7.2 on Ubuntu 20.04.
How to install beta php8.0 on CentOS8
How to change the timezone on Ubuntu
How to install kafkacat on Amazon Linux2
Install pyqt5 on ubuntu
Install Ruby on Ubuntu 20.04
How to install Docker
How to install docker-machine
Install Autoware on Ubuntu 18.04.5
How to install MySQL
Install Homebrew on Ubuntu 20.04
How to install ngrok
How to install and use Composer on an ECS instance on Ubuntu 16.04
How to install and configure the monitoring tool "Graphite" on Ubuntu
How to install Adopt OpenJDK on Debian, Ubuntu with apt (-get)
How to configure ubuntu to be used on GCP
How to Install Oracle JDK 1.8 in Ubuntu 18.04 LTS?
[Ruby on Rails] How to install Bootstrap in Rails
How to build a Pytorch environment on Ubuntu
How to run NullpoMino 7.5.0 on Ubuntu 20.04.1 64bit version
How to install c2ffi on Ubuntu, which automatically parses C header files
Install OpenJDK7 (JAVA) on ubuntu 14.04
Install Cybozu Office 10 on Ubuntu 20.4
Install Docker on Ubuntu Server 20.04
[Rails] How to install devise
How to deploy on heroku
Install zabbix agent (5.0) on Ubuntu 18.04
Install MAV Proxy on Ubuntu 18.04
Install Arudino IDE on Ubuntu 20
Install Java on WSL Ubuntu 18.04
How to install Boots Faces
Install Ubuntu Desktop 20.10 on RaspberryPi4
Install Arduino IDE on Ubuntu 20.04
Install raspi-config on Ubuntu 20.04 (LTS)
Install WordPress 5.5 on Ubuntu 20.04 LTS
Install PlantUML on Intellij on Ubuntu
Install Ubuntu Server 20.04 on Btrfs
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to install JDK8-10 (Mac)
How to add HDD to Ubuntu
How to install Ruby on an EC2 instance on AWS
Install MySQL 5.6 on CentOS6 [How to specify the version]
How to deploy jQuery on Rails
[Rails] How to install Font Awesome
How to deploy Laravel on CentOS 7
Install AWS IoT Greengrass on Ubuntu
How to install JMeter for Mac