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"