wildfly需要java的环境变量

安装

官网下载压缩包 wildfly官网下载
在这里插入图片描述
上传到linux服务器中,然后解压,并修改目录名称

tar -xvf wildfly-10.0.0.Final.tar.gz
mv wildfly-10.0.0.Final wildfly

在这里插入图片描述

  • bin目录下的standalone.sh是启动文件
  • standalone目录下configuration目录下standalone.xml为配置文件

启动

进入到bin目录下,运行

./standalone.sh

如果出现权限问题,使用sudo -E ./standalone.sh,或者先拿到root权限再执行运行命令
执行成功后可以通过浏览器默认路径 IP:8080 访问,显示以下界面启动成功
在这里插入图片描述
如果浏览器无法访问,需要进入配置文件,将文件中的所有127.0.0.1修改为0.0.0.0

cd wildfly/standalone/configuration/standalone.xml

自签证书配置SSL

  • 进入linux系统jre的bin目录下,执行以下代码生成自签证书

    keytool -genkey -alias "pccw" -keyalg "RSA" -keystore "/home/pccw/cert/pccw.keystore" -dname "CN=172.2.2.2 , OU=PCCW.COM , O=PCCW, L=GuangDong, 
    ST=ShenZhen, C=CN" -keypass 000000 -storepass 000000 -validity 730
    
    • CN= 写服务端的ip或域名,OU= O= L= ST= C= 可以随便写,validity 是证书有效期 默认是 90天,730 等于2年
    • -keystore: 生成路径 ; -keypass/-storepass: 设置密码,后续配置证书时需要
    keytool -export -file "/home/pccw/cert/pccw.crt" -alias "pccw" -keystore "/home/pccw/cert/pccw.keystore"
    
  • 查看/home/pccw/cert 路径下是否已经生成证书
    在这里插入图片描述

  • configuration目录下新建目录cert,将证书移动到cert文件夹下

  • 配置wildfly的SSL,进入配置文件

    cd wildfly/standalone/configuration/standalone.xml
    
  • 找到<security-realms>标签,在里边新增一下内容

    <security-realm name="SslRealm">
    	<server-identities>
            <ssl>
                    <keystore path="./cert/pccw.keystore"  relative-to="jboss.server.config.dir" alias="pccw"  keystore-password="000000"/>
            </ssl>
        </server-identities>
    </security-realm>
    

    *path: 是证书的路径;relative-to: 固定写法; alias/keystore-password: 生成证书时所设置; *

  • 找到以下位置,增加配置
    在这里插入图片描述

 <https-listener name="https" socket-binding="https" security-realm="SslRealm" enable-http2="true"/>
  • 重启wildfly,浏览器访问 IP:8443 ,显示wildfly界面则配置成功

配置开机自启动

开机自启动参考

  • 进入 /etc/systemd/system目录下,编辑rc-local.service,正常是有三个部分组成

    • [Unit] 段: 启动顺序与依赖关系
    • [Service] 段: 启动行为,如何启动,启动类型
    • [Install] 段: 定义如何安装这个配置文件,即怎样做到开机启动
      在这里插入图片描述

    如果没有Install,可以添加复制以下内容添加进去

    [Install]
    WantedBy=multi-user.target
    Alias=rc-local.service
    
  • 编辑/etc/rc.local

    sudo vim /etc/rc.local 
    
  • 写入以下内容

    #!/bin/sh -e
    #rc.local
    #This script is executed at the end of each multiuser runlevel.
    #Make sure that the script will "exit 0" on success or any other
    #value on error.
    #In order to enable or disable this script just change the execution
    #bits.
    #By default this script does nothing.
    #这里写入你要执行的命令;或者脚本(16.04之前版本只需要操作这里就ok了)
    
    #默认开机自动wildfly
    bash /ec/uat/product/wildfyec/bin/standalone.sh > /ec/uat/product/wildfyec/standalone/log/wildfyec.log 2>&1 &
    
    exit 0
    
  • 创建软链接

    ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/ 
    
  • 加权限

    sudo chmod +x /etc/rc.local
    
  • 启用服务

    sudo systemctl enable rc-local
    
  • 启动服务并检查状态,显示active,则表示已激活

    sudo systemctl start rc-local.service
    sudo systemctl status rc-local.service
    
  • 重启服务器 sudo reboot,查看是否自启动成功

如果启动失败,查看日志,如果显示没有java的环境变量,需要修改启动文件,

sudo vim wildfly/bin/standalone.sh

在文件开头添加刷新环境变量配置

source /etc/profile
echo "$JAVA_HOME"

在这里插入图片描述

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐