云网牛站
所在位置:首页 > Linux云服务器 > 在Ubuntu 18.04、Debian 10/9上安装WildFly的步骤

在Ubuntu 18.04、Debian 10/9上安装WildFly的步骤

2019-04-03 16:00:20作者:陈学力稿源:云网牛站

本文介绍在Ubuntu 18.04、Debian 10、Debian 9上安装WildFly (JBoss) Application Server的步骤,它是个用Java编写并由Red Hat开发的应用服务器,当前最新版本是WildFly 16.0.0。

 

第1步:安装Java

WildFly是用Java编写的,所以需要安装Java,在Ubuntu/Debian上安装Java有两种选择:

1、安装OpenJDK。

2、安装Java SE Development Kit。

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

sudo apt update

sudo apt -y install default-jdk

从上面的命令安装的默认Java版本是Java 10+,要说明的是,WildFly支持此版本:

$ java --version

openjdk 10.0.2 2018-07-17

OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)

OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

参考:Ubuntu系统中Java环境JDK 10的安装、配置、测试使用PPA在Ubuntu、Linux Mint或Debian系统中安装java 11

 

第2步:下载及安装WildFly 16.0.0

下载请到WildFly网站,我们要下载及安装的版本是WildFly 16.0.0:

wget https://download.jboss.org/wildfly/16.0.0.Final/wildfly-16.0.0.Final.tar.gz

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

tar xvf wildfly-16.0.0.Final.tar.gz

将生成的文件夹移动到/opt/wildfly:

sudo mv wildfly-16.0.0.Final/ /opt/wildfly

接下来配置以完成WildFly 16.0.0的全部安装过程。

 

第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 Application Server状态:

sudo systemctl status wildfly

在Ubuntu 18.04、Debian 10/9上安装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

系统将要求你选择要添加的用户类型,由于这是第一个用户,我们希望将其设为admin,选择a:

What type of user do you wish to add? 

a) Management User (mgmt-users.properties) 

b) Application User (application-users.properties)

(a):

为用户提供所需的用户名:

Enter the details of the new user to add.

Using realm 'ManagementRealm' as discovered from the existing property files.

Username : ywnz

为用户设置密码:

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 'ywnz' for realm 'ManagementRealm'

Is this correct yes/no? yes

Added user 'ywnz' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'

Added user 'ywnz' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'

Added user 'ywnz' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'

Added user 'ywnz' 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-groups.properties

 

第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

参考:将.bashrc文件恢复到Ubuntu中的默认设置

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

# jboss-cli.sh --connect

[standalone@localhost:9990 /] version

JBoss Admin Command-line Interface

JBOSS_HOME: /opt/wildfly

Release: 8.0.0.Final

Product: WildFly Full 16.0.0.Final

JAVA_HOME: null

java.version: 10.0.2

java.vm.vendor: Oracle Corporation

java.vm.version: 10.0.2+13-Ubuntu-1ubuntu0.18.04.4

os.name: Linux

os.version: 4.15.0-46-generic

现在可以进行从Web Interface访问WildFly管理控制台的操作了。

默认情况下,可以在9990端口上的localhost IP上访问控制台:

# 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,如下:

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

确认:

$ 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,只要配置的IP地址即可访问到WildFly Web控制台,如下图:

在Ubuntu 18.04、Debian 10/9上安装WildFly的步骤

使用前面创建的用户名和密码进行登陆,如无问题的话就可以出来WildFly控制台界面了:

在Ubuntu 18.04、Debian 10/9上安装WildFly的步骤

看到如上图,说明已在Ubuntu 18.04/Debian上成功安装了WildFly服务器。

 

相关主题

在CentOS 7系统中安装WildFly 14.0.1

精选文章
热门文章