wildflyでのサービス公開手順 CentOS7+Nginx[http2]+JDK1.8+Wildfly10.1+MariaDB10.1.22

■アップデート

yum update

■JDK1.8 install

yum install java-1.8.0-openjdk-devel
java -version

■Wildfly 10

useradd wildfly
passwd wildfly
curl -O http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz
tar zxvf wildfly-10.1.0.Final.tar.gz -C /opt

cd /opt
chown -R wildfly:wildfly ./wildfly-10.1.0.Final/
cd /opt/wildfly-10.1.0.Final/
./bin/add-user.sh
vi ./standalone/configuration/standalone.xml
(127.0.0.1をgloval IPに変更)

■Nginx
yumの場合は以下。http2に対応するためビルドから(後述)

vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1


yum -y --enablerepo=nginx install nginx

■Nginx(https2)
ビルドツール・依存関係ライブラリをインストール
ここからOpenSSL最新版取得

yum groupinstall "Development Tools"
yum install pcre pcre-devel zlib zlib-devel

curl -L -O https://www.openssl.org/source/openssl-1.1.0e.tar.gz

ここからNginx(Stable Version)のURLを取得

curl -L -O https://nginx.org/download/nginx-1.12.0.tar.gz
tar zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/

下記の内容でconfigure

./configure  \
  --prefix=/etc/nginx \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --pid-path=/var/run/nginx.pid \
  --lock-path=/var/run/nginx.lock \
  --http-client-body-temp-path=/var/cache/nginx/client_temp \
  --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
  --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
  --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
  --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_sub_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_mp4_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_stub_status_module \
  --with-http_auth_request_module \
  --with-threads \
  --with-stream \
  --with-stream_ssl_module \
  --with-http_slice_module \
  --with-mail \
  --with-mail_ssl_module \
  --with-file-aio \
  --with-http_v2_module \
  --with-ipv6 \
  --with-openssl=../openssl-1.1.0e/

■MariaDB

vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1


yum -y install MariaDB-server MariaDB-client
systemctl start mariadb
systemctl enable mariadb

mysql -p

show variables like 'char%';
vi /etc/my.cnf.d/server.cnf

[mysqld]
character-set-server=utf8


mysql -p

show variables like 'char%';
CREATE DATABASE dbname;
SELECT user,host FROM mysql.user;
GRANT ALL PRIVILEGES ON `dbname`.* TO 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `dbname`.* TO 'username'@'127.0.0.1' IDENTIFIED BY 'password';

update mysql.user set password=password('password') where user = 'root';
flush privileges;

exit

■firewall確認

firewall-cmd --list-all
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --add-port=9990/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all

■ひとまず動作確認(まだNGINX未設定)

su - wildfly
cd /opt/
http://ipaddress:8080/
http://ipaddress:9990/
(管理画面からJDBCの設定やデプロイなどを設定。面倒なので、standalone.xmlを上書き)

■おまけ
wildfly停止
./jboss-cli.sh –connect command=:shutdown

wildflyの起動 nohup でも良いけど、サービス登録したい
http://www.dimasrio.com/2016/07/setup-wildfly-10-standalone-di-centos-7.html