1. 請先確定好有安裝 Java 1.5、Apache2、mod_jk, Java 1.5 可能要到 Sun 的網站或是 SuSE FTP 下載,其他的 SuSE 的安裝選項都有。
2. 到 JBoss 網站的下載頁面 http://labs.jboss.com/portal/jbossas/download ,下載 JBoss 的 Installer 到電腦裡面,我下載的檔名為 jems-installer-1.2.0.CR1.jar ,這是 4.0.5 GA 的版本。
( Installer 有安裝對話視窗,比較方便使用 )
3. 安裝畫面有語系、安裝種類、路徑、資料庫等,依照您所需要的輸入即可,目前是選用「全部安裝」,安裝到預設路徑: /usr/local/jboss-4.0.5.GA。
註1:如果資料庫選擇的是 MySQL,安裝完畢之後,請將 /usr/share/java 目錄中的 mysql-connector-java-x.x.x.jar 複製到 $JBOSS_HOME/server/default/lib 裡面。
註2:資料庫的部份,也請記得修改 Connection URL 裡面的字串為 資料庫主機的 IP。
4. 大多部分的說明,會請使用者直接執行 $JBOSS_HOME/bin/run.sh 就可以啟動 JBOSS,不過每次電腦重新啟動之後,還要系統 or 程式人員手動登入啟動總是不方便。所以可以看一下 $JBOSS_HOME/bin 這個目錄,裡面有個叫做 jboss_init.suse.sh 的Script。請將這個檔案複製到目錄 /etc/init.d 並更名為 jboss。
5. 修改 /etc/init.d/jboss,請依照個人的環境設定,以下為參考
原始:JBOSS_HOME=${JBOSS_HOME:-"/opt/jboss"}
改成:JBOSS_HOME=${JBOSS_HOME:-"/usr/local/jboss-4.0.5.GA"}
原始:JAVAPTH=${JAVAPTH:-"/usr/java/j2sdk1.4.1/bin"}
改成:JAVAPTH=${JAVAPTH:-"$JAVA_HOME/bin"}
原始:JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c all"}
改成:JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh"}
原始:JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/opt/jboss/log/jboss.log"}
改成:JBOSS_CONSOLE=${JBOSS_CONSOLE:-"$JBOSS_HOME/log/jboss.log"}
如果 console 設定密碼後,執行 /etc/init.d/jboss stop 而無法關閉 JBOSS 的問題,需要做以下的修改:
原始:CMD_STOP="java -classpath $JBOSSCP org.jboss.Shutdown --shutdown
改成:CMD_STOP="java -classpath $JBOSSCP org.jboss.Shutdown --shutdown --user=帳號 admin --password=密碼"
6. 由於JBoss 4.0.5 GA 有個發行後的 bug,log 會顯示
13:34:48,389 INFO [[/web-console]] MonitorsFolder: Failed to init plugin, null
13:34:48,398 INFO [[/web-console]] UCLs: Failed to init plugin, null
13:34:48,433 INFO [[/web-console]] JMS Message: Failed to init plugin, null
13:34:48,439 INFO [[/web-console]] JSR77 WebModule: Failed to init plugin, null
13:34:48,451 INFO [[/web-console]] J2EEFolder: Failed to init plugin, null
13:34:48,464 INFO [[/web-console]] AOPFolder: Failed to init plugin, null
13:34:48,466 INFO [[/web-console]] SystemFolder: Failed to init plugin, null
13:34:48,504 INFO [[/web-console]] MBeans: Failed to init plugin, null
13:34:48,515 INFO [[/web-console]] JSR77 Domains and Servers: Failed to init plugin, null
13:34:48,521 INFO [[/web-console]] JSR77 EJBModules and EJBs: Failed to init plugin, null
13:34:48,527 INFO [[/web-console]] JSR77 J2EE Apps: Failed to init plugin, null
所以需要修改 $JBOSS_HOME/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF/jboss-web.xml,將原始的
<jboss-web>
<!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users.
-->
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
修改為
<jboss-web>
<!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users.
-->
<security-domain>java:/jaas/jmx-console</security-domain>
<depends>jboss.admin:service=PluginManager</depends>
</jboss-web>
7. 建立新的使用者,名稱為 jboss,並於 /usr/local/jboss-4.0.5.GA 中新增目錄,名稱為 log 。
8. 以指令 chown jboss:root /usr/local/jboss-4.0.5.GA -R,以變更 JBoss 目錄權限。
9. 使用 insserv 或是 YaST 設定於開機時自動啟動 jboss,如原本有安裝 Tomcat ,可以順便將其由啟動程序中關閉 。
10. 修改 /etc/apache2/conf.d/jk.conf 為:
<IfModule mod_jk.c>
JkWorkersFile /路徑/workers.properties # mod_jk 的詳細設定
JkLogFile /路徑/jk.log
JkLogLevel info
JkMount /*.jsp node1 # 如果 Apache2 得到請求為 *.jsp,例: index.jsp,會將請求傳予 Tomcat
JkMount /jmx-console node1 # 如果 Apache2 得到請求路徑為 /jmx-console,則會將請求轉給 Tomcat
JkMount /jmx-console/* node1 # (略)
JkMount /web-console node1 # (略)
JkMount /web-console/* node1 # (略)
JkMount /status node1 # (略)
</IfModule>
11. 新建 workers.properties,放置的位置與 jk.conf 裡面的設定相同 :
worker.list=node1 # 節點名稱,請注意顏色,需同名
# Server 1
worker.node1.port=8009 # Tomcat 通訊 Port 號
worker.node1.host=127.0.0.1 # Tomcat 主機位址,可用 DNS 或 IP
worker.node1.type=ajp13 # 連接種類
worker.node1.lbfactor=1 # Loadbalanc 附載比重,如有 LB 環境,此值大小影響分配到的附載量
12. 執行 /etc/init.d/jboss start 即可啟動 jboss,啟動訊息的部分都存在 $JBOSS_HOME/log 目錄的 jboss.log 檔案內。
13. 可能會有人要輸入 http://localhost/ 就可以看到 http://localhost:8080 的 JBoss 畫面,那請修改 http.conf 或是 Virtual Host 檔案的設定 DocumentRoot 為 JBoss Tomcat 的目錄:
DocumentRoot /usr/local/jboss-4.0.5.GA/server/default/deploy/jbossweb-tomcat55.sar/ROOT.war
並且增加目錄權限
<Directory "/usr/local/jboss-4.0.5.GA/server/default/deploy/jbossweb-tomcat55.sar/ROOT.war">
Options None
AllowOverride None
Order deny,allow
deny from all
Allow from all
</Directory>
重新啟動 Apache2 應該就可以囉。