如何在 Ubuntu 22.04|20.04|18.04 上安装 WildFly (JBoss)如何在 Ubuntu 22.04|20.04|18.04 上安装 WildFly (JBoss)如何在 Ubuntu 22.04|20.04|18.04 上安装 WildFly (JBoss)如何在 Ubuntu 22.04|20.04|18.04 上安装 WildFly (JBoss)
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

如何在 Ubuntu 22.04|20.04|18.04 上安装 WildFly (JBoss)

发表 admin at 2025年2月28日
类别
  • 未分类
标签

本指南将引导您完成在 Ubuntu 22.04|20.04|18.04 上安装 WildFly (JBoss) 服务器的过程。 WildFly 以前称为 JBoss,是由 Red Hat 开发的用 Java 编写的应用服务器。 WildFly Application Server 是 Java Enterprise Edition 8 平台规范的异常快速、轻量级且功能强大的实现。

截至撰写本文时,WildFly 29 是 JBoss 开源应用服务器产品系列中的最新版本。本文简要概述了如何在 Ubuntu 22.04|20.04|18.04 上下载并安装 WildFly 最新可用版本以进行应用程序开发。

步骤1:在Ubuntu上安装Java JDK

WildFly 是用 Java 编写的,需要先安装它。在 Ubuntu Linux 系统上安装 Java 有两种选择。

  • 安装 OpenJDK
  • 安装Java SE开发工具包

获取 Java 的最简单方法是通过运行以下命令在 Ubuntu 系统上安装 OpenJDK。

sudo apt update
sudo apt -y install default-jdk

通过上述命令安装的默认 Java 版本是 Java 10+。这是由 WildFly 支持的。

$ java --version
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1, mixed mode, sharing)

第2步:下载WildFly安装档案

安装curl和wget工具

sudo apt install curl wget

下载文件之前,请检查 WildFly 下载页面以获取最新版本。在这里我们将下载WildFly 29.x。

WILDFLY_RELEASE=$(curl -s https://api.github.com/repos/wildfly/wildfly/releases/latest|grep tag_name|cut -d '"' -f 4)
wget https://github.com/wildfly/wildfly/releases/download/${WILDFLY_RELEASE}/wildfly-${WILDFLY_RELEASE}.tar.gz

下载文件后,将其解压缩。

tar xvf wildfly-${WILDFLY_RELEASE}.tar.gz

将生成的文件夹移至 /opt/wildfly。

sudo mv wildfly-${WILDFLY_RELEASE} /opt/wildfly

步骤 3:为 WildFly 配置 Systemd

现在让我们创建一个将运行 WildFly 服务的系统用户和组。

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

创建 WildFly 配置目录。

sudo mkdir /etc/wildfly

从 /opt/wildfly/docs/contrib/scripts/systemd/ 目录复制 WildFly systemd 服务、配置文件和启动脚本模板。

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/
sudo chmod +x /opt/wildfly/bin/launch.sh

设置 /opt/wildfly 权限。

sudo chown -R wildfly:wildfly /opt/wildfly

重新加载 systemd 服务。

sudo systemctl daemon-reload

启动并启用 WildFly 服务:

sudo systemctl start wildfly
sudo systemctl enable wildfly

确认 WildFly 应用程序服务器状态。

sudo systemctl status wildfly

示例输出:

服务应绑定到端口 8080。

$ ss -tunelp | grep 8080
tcp    LISTEN   0   128    0.0.0.0:8080  0.0.0.0:*  users:(("java",pid=6854,fd=389)) uid:999 ino:30339 sk:3 <-> 

第 4 步:添加 WildFly 用户

默认情况下,WildFly 16 现在已分发并为管理界面启用了安全性。我们需要创建一个可以访问 WildFly 管理控制台或远程使用 CLI 的用户。提供了一个用于管理用户的脚本。

通过执行命令来运行它:

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

系统将要求您选择要添加的用户类型。由于这是第一个用户,我们希望将其设为管理员。所以选择a。

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 : computingforgeeks

为用户设置密码:

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 : <Enter Password>
Re-enter Password :  <Confirm Password>

按 Enter 并同意后续提示以完成用户创建。

What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: <Enter>
 About to add user 'computingforgeeks' for realm 'ManagementRealm'
 Is this correct yes/no? yes
 Added user 'computingforgeeks' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
 Added user 'computingforgeeks' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
 Added user 'computingforgeeks' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
 Added user 'computingforgeeks' 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 

请注意:

用户信息保存在:/opt/wildfly/domain/configuration/mgmt-users.properties
组信息保存在:/opt/wildfly/standalone/configuration/mgmt-组.属性

第5步:访问WildFly管理控制台

为了能够从当前 shell 会话运行 WildFly 脚本,请将 /opt/wildfly/bin/ 添加到您的 ` PATH。

cat >> ~/.bashrc <<EOF
export WildFly_BIN="/opt/wildfly/bin/"
export PATH=\$PATH:\$WildFly_BIN                                                                                                                    
EOF

获取 bashrc 文件的源。

source ~/.bashrc

现在,通过使用 jboss-cli.sh 命令从 CLI 连接到 WildFly 管理控制台进行测试。

$ jboss-cli.sh --connect
Authenticating against security realm: ManagementRealm
Username: computingforgeeks
Password:
[standalone@localhost:9990 /] version
JBoss Admin Command-line Interface
JBOSS_HOME: /opt/wildfly
Release: 29.0.1.Final
Product: WildFly Full 29.0.1.Final
JAVA_HOME: null
java.version: 11.0.13
java.vm.vendor: Ubuntu
java.vm.version: 11.0.13+8-Ubuntu-0ubuntu1
os.name: Linux
os.version: 5.13.0-19-generic
[standalone@localhost:9990 /] exit

从 Web 界面访问 WildFly 管理控制台

默认情况下,可以通过本地主机 IP 的端口 9990 访问控制台。

$ ss -tunelp | grep 9990
tcp    LISTEN   0    50    127.0.0.1:9990  0.0.0.0:* users:(("java",pid=6769,fd=404)) uid:999 ino:30407 sk:3 <-> 

我们可以在可从本地服务器外部访问的不同 IP 地址上启动它。编辑 /opt/wildfly/bin/launch.sh 如下所示:

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

我们添加了 -bmanagement=0.0.0.0 来启动脚本行。这会将“管理”接口绑定到所有可用的 IP 地址。

重启wildfly服务

sudo systemctl restart wildfly

检查服务状态以确认服务成功

$ systemctl status  wildfly
● wildfly.service - The WildFly Application Server
     Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-12-24 12:11:21 EAT; 6s ago
   Main PID: 8205 (launch.sh)
      Tasks: 70 (limit: 9482)
     Memory: 159.8M
        CPU: 12.265s
     CGroup: /system.slice/wildfly.service
             ├─8205 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0
             ├─8206 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0 -bmanagement=0.0.0.0
             └─8305 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava>

Des 24 12:11:22 ubuntu22 systemd[1]: Started The WildFly Application Server.

确认端口 9990 正在侦听:

$ ss -tunelp | grep 9990
tcp    LISTEN   0  50     0.0.0.0:9990  0.0.0.0:*  users:(("java",pid=9496,fd=320)) uid:999 ino:73367 sk:c <->

打开浏览器和 URL http://serverip:9990 以访问 WildFly Web 控制台。

使用之前创建的用户名和密码进行身份验证。 WildFly 控制台将是下一个显示的窗口。

您已在 Ubuntu 22.04|20.04|18.04 上成功安装 WildFly 应用程序服务器。请访问 WildFly 文档页面以进一步阅读。

©2015-2025 Norria support@alaica.com