关于WildFly的安装,参考:Ubuntu 16.04 安装 WildFly(http://www.linuxdiyf.com/linux/22663.html)
1.安装WildFly
安装Java:
$ sudo apt-get install default-jdk default-jre
添加wildfly用户:
$ sudo groupadd -r wildfly
$ sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
下载wildfly:
$ cd /opt
$ sudo wget http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.tar.gz
解压文件:
$ sudo tar -xvzf wildfly-10.0.0.Final.tar.gz
$ sudo mv wildfly-10.0.0.Final wildfly
更改目录权限:
$ sudo chown wildfly:wildfly -R /opt/wildfly/
2.安装配置Nginx
$ sudo apt-get install nginx
编辑默认的Nginx虚拟主机配置文件:
$ sudo vim /etc/nginx/sites-enabled/default
删除如下一行:
listen [::]:80 default_server;
创建Nginx虚拟主机配置文件:
$ sudo vim /etc/nginx/sites-available/wildfly
upstream wildfly {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name your_domain.com;
access_log /var/log/nginx/wildfly.access.log;
error_log /var/log/nginx/wildfly.error.log;
proxy_buffers 16 64k;
proxy_buffer_size 128k;
location / {
proxy_pass http://wildfly;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
注意替换上面的域名。
使配置生效:
$ sudo ln -s /etc/nginx/sites-available/wildfly /etc/nginx/sites-enabled
$ sudo systemctl restart nginx
3.配置WildFly
创建wildfly配置文件:
$ sudo vim /etc/default/wildfly
写入内容:
WILDFLY_USER="wildfly"
STARTUP_WAIT=180
SHUTDOWN_WAIT=30
WILDFLY_CONFIG=standalone.xml
WILDFLY_MODE=standalone
WILDFLY_BIND=0.0.0.0
创建一个wildfly启动脚本:
$ sudo vim /opt/wildfly/bin/launch.sh
写入内容:
#!/bin/sh
if [ "x$WILDFLY_HOME" = "x" ]; then
WILDFLY_HOME=/opt/wildfly
fi
if [ "x$1" = "xdomain" ]; then
echo 'Starting Wildfly in domain mode.'
$WILDFLY_HOME/bin/domain.sh -c $2 -b $3
else
echo 'Starting Wildfly in standalone mode.'
$WILDFLY_HOME/bin/standalone.sh -c $2 -b $3
fi
添加可执行权限:
$ sudo chmod 755 /opt/wildfly/bin/launch.sh
创建wildfly服务:
$ sudo vim /etc/systemd/system/wildfly.service
写入如下内容:
[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=nginx.service
[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=/etc/default/wildfly
User=wildfly
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
StandardOutput=null
[Install]
WantedBy=multi-user.target
启动WildFly服务:
$ sudo systemctl daemon-reload
$ sudo systemctl start wildfly
$ sudo systemctl enable wildfly
首先停止Wildfly服务,然后运行add-user.sh脚本添加用户:
$ sudo systemctl stop wildfly
$ cd /opt/wildfly/bin
$ sudo ./add-user.sh
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 : wildflyadmin
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 :
WFLYDM0102: Password should have at least 1 non-alphanumeric symbol.
Are you sure you want to use the password entered yes/no? yes
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 'wildflyadmin' for realm 'ManagementRealm'
Is this correct yes/no? yes
Added user 'wildflyadmin' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'wildflyadmin' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'wildflyadmin' with groups to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'wildflyadmin' 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="VGVzdDEyMzQ1Ng==" />
4.完成安装
重启服务:
$ sudo systemctl restart nginx
$ sudo systemctl start wildfly
使用浏览器访问:http://your_domain.com
使用前面的创建的管理员用户登录: