MacOS上にVagrantを入れてCentOSを動かし、さらにJbossなるものを動作させてみたいと思う。
ネットワーク設定
CentOSの設定を変更
hostsファイル
hostsファイルにゲストOS情報の記載がないと、以下のようなエラーが出力され、起動が若干おそいので、/etc/hostsへゲストOSのIPアドレスとホスト名(uname -a)を追記。
WARN [com.arjuna.ats.arjuna] (Transaction Expired Entry Monitor) ARJUNA12210: Unable to use InetAddress.getLocalHost() to resolve address.
ゲストOSのホスト名を確認
$ hostname
vagrant-centos64.vagrantup.com
ホスト名とIPアドレスを追記
$ vi /etc/hosts
以下を追記
192.168.33.10 vagrant-centos64.vagrantup.com
serviceファイル
影響度合いが不明なのだが、8080を追加
$ vi /etc/service
ネットワークの再起動
ネットワーク関連のファイルを修正した場合には、再起動が必要
$ service network restart
JRE Linux 7u51のインストール
Jbossの動作にはJREを入れる必要があります。
$ rpm -ivh jdk-7u51-linux-x64.rpm
Jbossのインストール
Jbossの解凍
/opt に圧縮ファイルを置いて解凍
$ cp jboss-as-7.1.0.Final.zip /opt
$ unzip jboss-as-7.1.0.Final.zip
起動ポート&IPアドレスの変更
対象ファイル
/opt/jboss-as-7.1.0.Final/standalone/configuration/standalone.xml
(1)ファイルで8080と記載されている部分を80へ変更する
<socket-binding name="http" port="8080"/>
(2)起動するとlocalhost(127.0.0.1)で待ちになるようで、インターフェイスのIPアドレスを設定する必要がある。以下でIPアドレスが記述された2箇所は、デフォルトでは127.0.0.1となっています。
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:192.168.33.10}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:192.168.33.10}"/>
</interface>
</interfaces>
Jbossを起動する
$ cd /opt/jboss-as-7.1.0.Final/bin
$ ./standalone.sh
ゲストOSのブラウザから接続してJbossが見れたらOK!
http://192.168.33.10/
Jbossを使用する準備
管理ユーザの追加
管理ユーザを追加しないと何もできませんので。
/opt/jboss-as-7.1.0.Final/bin/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.
Realm (ManagementRealm) : admin
Username : admin
Password :
Re-enter Password :
The username 'admin' is easy to guess
Are you sure you want to add user 'admin' yes/no? yes
About to add user 'admin' for realm 'admin'
Is this correct yes/no? yes
Helloプログラム
standalone/deploymentsに移動して、ディレクトリtest.warを作成(.warを付けないと、Webモジュールと認識されない)。
test.war配下に移動してtest.jspを作る。
<html>
<head>
</head>
<body>
1 + 2 = <%= 1 + 2 %>
</body>
</html>
test.warと同階層のディレクトリ(test.war配下ではない)に、test.war.dodeployを作成。
touch test.war.dodeploy
数秒待つとdeployedという拡張子に変わる。
$ ls
README.txt test.war test.war.deployed
ゲストOSのブラウザから接続してtest.jspが見れたらOK!
http://192.168.33.10:8080/test/test.jsp