Install JBoss 5
Install JBoss 5
1 on CentOS
This post will cover installing JBoss 5.1 on CentOS 5.x.
NOTE: If you wish to install JBoss 7.1 on CentOS, please see my post here:
http://www.davidghedini.com/pg/entry/install_jboss_7_on_centos
We'll also set up JBoss to run as a service
I did my installation below on CentOS 5.5. This should work for RHEL and Fedora as
well.
Firstly, let's outline the steps we will be taking:
1. Download and Install the Java Development Kit (JDK)
2. Download and Install JBoss 5.1 Application Server
3. Create the user, jboss, who will own and run JBoss
4. Set the required JAVA_HOME and JBOSS_HOME paths
5. Create a start/stop/restart script for JBoss
6. Configure JBoss to run as a service
7. Change the JBoss Admin Console password
8. Set memory parameters for JBoss using JAVA_OPTS
9. Configure JBoss to run on port 80
10. Notes: Securing the JMX Console, Web Console, JBossWS, and Tomcat Status.
1.
Change to the /usr/java directory we created and install the JDK using 'sh /opt/jdk6u24-linux-x64.bin'
1.
in 17s
8.
9. 2011-01-02 02:03:02 (7.56 MB/s) - `jboss-5.1.0.GA.zip' saved [133466607/13
3466607]
Step 3: Create the user, jboss, who will own and run JBoss
Since we will want to run JBoss as a non-root user with minimal privileges, we'll create
a user, jboss, who will own the JBoss files and JBoss will run under his account.
To do this, we can need to the following.
Create a new group, jboss, and then create the user jboss and add the user to the
jboss group.
1.
To set the JAVA_HOME for users, we add this to the user ~/.bashrc or ~/.bash_profile
of the user. We can also add it /etc/profile and then source it to give to all users.
1. JAVA_HOME=/usr/java/jdk1.6.0_24
2. export JAVA_HOME
3. PATH=$JAVA_HOME/bin:$PATH
4. export PATH
Once you have added the above to ~/.bash_profile or ~/.bashrc, you should su to the
user jboss and verify that the JAVA_HOME and JBOSS_HOME are set correctly.
1.
For our JBoss script we will simply copy the existing jboss_init_redhat.sh script located
at at /usr/share/jboss-5.1.0.GA/bin, copy it to /etc/init.d and rename it to 'jboss':
So, as root:
1.
In the jboss script (shown completed below), make the following changes:
1. Add lines 3,4, and 5:
# description: JBoss Start Stop Restart
# processname: jboss
# chkconfig: 234 20 80
2. Line 21, Set the JBOSS_HOME to where we unpacked JBoss in step 2 above:
JBOSS_HOME=${JBOSS_HOME:-"/usr/share/jboss-5.1.0.GA"}
3. Line 27. Set the JAVA_HOME to where we installed the JDK in step 1 above:
JAVAPTH=${JAVAPTH:-"/usr/java/jdk1.6.0_24"}
4. Add line 33, which sets the JBOSS_HOST to 0.0.0.0, allowing JBoss to bind to any
IP.
JBOSS_HOST="0.0.0.0"
1. #!/bin/sh
2. #
3. # description: JBoss Start Stop Restart
4. # processname: jboss
5. # chkconfig: 234 20 80
7. #
8. # JBoss Control Script
9. #
10. # To use this script run it as root - it will switch to the specified user
11. #
12. # Here is a little (and extremely primitive) startup/shutdown script
13. # for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
14. # it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
15. # All this can be changed in the script itself.
16. #
17. # Either modify this script for your requirements or just ensure that
18. # the following variables are set correctly before calling the script.
19.
20. #define where jboss is - this is the directory containing directories log, bin, conf
etc
21. JBOSS_HOME=${JBOSS_HOME:-"/usr/share/jboss-5.1.0.GA"}
22.
23. #define the user under which jboss will run, or use 'RUNASIS' to run as the curr
ent user
24. JBOSS_USER=${JBOSS_USER:-"jboss"}
25.
47. fi
48.
49. if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
50. # ensure the file exists
51. touch $JBOSS_CONSOLE
52. if [ ! -z "$SUBIT" ]; then
53.
54. fi
55. fi
56.
57. if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
58. echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
59. echo "WARNING: ignoring it and using /dev/null"
60. JBOSS_CONSOLE="/dev/null"
61. fi
62.
63. #define what will be done with the console log
64. JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
65.
66. JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
67. JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jbos
s.Shutdown --shutdown"}
68.
69. if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
70. export PATH=$PATH:$JAVAPTH
71. fi
72.
73. if [ ! -d "$JBOSS_HOME" ]; then
74. echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
75. exit 1
76. fi
77.
78. echo JBOSS_CMD_START = $JBOSS_CMD_START
79.
80. case "$1" in
81. start)
82.
cd $JBOSS_HOME/bin
83.
if [ -z "$SUBIT" ]; then
84.
85.
86.
87.
fi
88.
;;
89. stop)
90.
if [ -z "$SUBIT" ]; then
91.
$JBOSS_CMD_STOP
92.
else
93.
$SUBIT "$JBOSS_CMD_STOP"
94.
fi
95.
;;
96. restart)
97.
$0 stop
98.
$0 start
99.
;;
100.
101.
102.
*)
echo "usage: $0 (start|stop|restart|help)"
esac
1.
Stop JBoss:
1.
If you have any difficulties, check the logs and also insure that port 8080 is open
Step 10: Notes: Secure the JBoss Web Console, JMX Console,
JBossWS, and Tomcat Status Page.
This section will cover some simple and most basic methods of securing the consoles.
If you are simply running JBoss locally to have a look at it, you can skip this bit.
I've seen more elegent presentations of securing JBoss, so you may want to Google
this if you find below a bit clunky.
As with anything related to your application and server security, please consult the
docs.
to users with the role JBossAdmin. Edit the roles to what you want and
3.
4.
5.
<security-constraint>
6.
<web-resource-collection>
7.
<web-resource-name>HtmlAdaptor</web-resource-name>
8.
<description>An example security config that only allows users with the
9.
10.
11.
<url-pattern>/*</url-pattern>
12.
<http-method>GET</http-method>
13.
<http-method>POST</http-method>
14.
</web-resource-collection>
15.
<auth-constraint>
16.
<role-name>JBossAdmin</role-name>
17.
</auth-constraint>
18.
</security-constraint>
19.
-->
<web-resource-collection>
2.
<web-resource-name>HtmlAdaptor</web-resource-name>
3.
<description>An example security config that only allows users with the
4.
5.
</description>
6.
<url-pattern>/*</url-pattern>
7.
<http-method>GET</http-method>
8.
<http-method>POST</http-method>
9.
</web-resource-collection>
10.
<auth-constraint>
11.
<role-name>JBossAdmin</role-name>
12.
</auth-constraint>
13.
</security-constraint>
Next, still in the WEB-INF directory, edit the jboss-web.xml file, which will look as
below:
1. <!DOCTYPE jboss-web PUBLIC
2.
3.
"http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
4.
5. <jboss-web>
6.
7.
8.
9.
<security-domain>java:/jaas/jmx-console</security-domain>
10.
-->
11. </jboss-web>
Uncomment the security-domain so it appears thus:
1. <jboss-web>
2.
3.
<security-domain>java:/jaas/jmx-console</security-domain>
4.
5. </jboss-web>
At this point, the password for the JMX Console will be the same as the password we
set for the Admin Console at in in step 7a above. Both are using the java:/jaas/jmxconsole security domain.
You can, of course change this if you wish to create a stronger solution.
1. <security-constraint>
2.
<web-resource-collection>
3.
<web-resource-name>HtmlAdaptor</web-resource-name>
4.
<description>An example security config that only allows users with the
5.
6.
</description>
7.
<url-pattern>/*</url-pattern>
8.
<http-method>GET</http-method>
9.
<http-method>POST</http-method>
10.
</web-resource-collection>
11.
<auth-constraint>
12.
<role-name>JBossAdmin</role-name>
13.
</auth-constraint>
14.
</security-constraint>
5.
"http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
6.
7. <jboss-web>
8.
9.
10.
11.
12.
<security-domain>java:/jaas/web-console</security-domain>
13.
-->
14.
15.
16.
<depends>jboss.admin:service=PluginManager</depends>
17. </jboss-web>
<security-domain>java:/jaas/web-console</security-domain>
4.
5.
6.
7.
<depends>jboss.admin:service=PluginManager</depends>
8. </jboss-web>
1. <application-policy name="web-console">
2.
3.
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" fl
ag="required">
4.
<module-option name="usersProperties">web-consoleusers.properties</module-option>
5.
<module-option name="rolesProperties">web-consoleroles.properties</module-option>
6.
</login-module>
7.
</authentication>
8.
</application-policy>
1. <application-policy name="web-console">
2.
3.
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" fl
ag="required">
4.
<module-option name="usersProperties">props/web-consoleusers.properties</module-option>
5.
<module-option name="rolesProperties">props/web-consoleroles.properties</module-option>
6.
</login-module>
7.
</authentication>
8.
</application-policy>
Where 'WebSecret' is whatever you would like the password to be. If you wish to be
able to access the Web Console with the same password as for the Admin and JMX
console, simply use the same password here.
<web-resource-collection>
3.
<web-resource-name>ContextServlet</web-resource-name>
4.
<description>An example security config that only allows users with the
5.
6.
</description>
7.
<url-pattern>/*</url-pattern>
8.
<http-method>GET</http-method>
9.
<http-method>POST</http-method>
10.
</web-resource-collection>
11.
<auth-constraint>
12.
<role-name>friend</role-name>
13.
</auth-constraint>
14.
</security-constraint>
5.
"http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
6.
7. <jboss-web>
8.
9.
10. <security-domain>java:/jaas/JBossWS</security-domain>
11.
12.
13. <context-root>jbossws</context-root>
14.
15. </jboss-web>
In the /props directory you will find the jbossws-roles.properties and jbosswsusers.properties files.
The default role is 'friend' with user name 'Kermit' and password 'the frog'
jbossws-roles.properties:
<security-constraint>
<web-resource-collection>
4.
<web-resource-name>HtmlAdaptor</web-resource-name>
5.
<description>An example security config that only allows users with the
6.
7.
</description>
8.
<url-pattern>/status</url-pattern>
9.
<http-method>GET</http-method>
10.
<http-method>POST</http-method>
11.
</web-resource-collection>
12.
13.
<auth-constraint>
<role-name>TomcatStatus</role-name>
14.
</auth-constraint>
15.
</security-constraint>
16.
17.
18.
<login-config>
19.
<auth-method>BASIC</auth-method>
20.
<realm-name>TomcatStatus</realm-name>
21.
</login-config>
22.
23.
24.
25.
<security-role>
<role-name>TomcatStatus</role-name>
</security-role>
5.
"http://java.sun.com/dtd/web-app_2_3.dtd">
6.
7. <web-app>
8.
<display-name>Welcome to JBoss</display-name>
9.
<description>
10.
Welcome to JBoss
11. </description>
12. <servlet>
13.
<servlet-name>Status Servlet</servlet-name>
14.
<servlet-class>org.jboss.web.tomcat.service.StatusServlet</servlet-class>
15. </servlet>
16. <servlet-mapping>
17.
<servlet-name>Status Servlet</servlet-name>
18.
<url-pattern>/status</url-pattern>
19. </servlet-mapping>
20.
21.
22.
23. <security-constraint>
24.
<web-resource-collection>
25.
<web-resource-name>HtmlAdaptor</web-resource-name>
26.
<description>An example security config that only allows users with the
27.
28.
29.
<url-pattern>/status</url-pattern>
30.
<http-method>GET</http-method>
31.
<http-method>POST</http-method>
32.
</web-resource-collection>
33.
<auth-constraint>
34.
<role-name>TomcatStatus</role-name>
35.
</auth-constraint>
36.
</security-constraint>
37.
38.
39.
<login-config>
40.
<auth-method>BASIC</auth-method>
41.
<realm-name>TomcatStatus</realm-name>
42.
</login-config>
43.
44.
45.
46.
<security-role>
<role-name>TomcatStatus</role-name>
</security-role>
47.
48.
49.
50. </web-app>
<security-domain>java:/jaas/tomcat-status</security-domain>
4.
5. </jboss-web>
Go to /usr/share/jboss-5.1.0.GA/server/default/conf
Look for the following section:
1. <application-policy name="web-console">
2.
3.
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
4.
flag="required">
5.
<module-option name="usersProperties">props/web-consoleusers.properties</module-option>
6.
<module-option name="rolesProperties">props/web-consoleroles.properties</module-option>
7.
</login-module>
8.
</authentication>
9.
</application-policy>
<authentication>
3.
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
4.
flag="required">
5.
<module-option name="usersProperties">props/tomcat-statususers.properties</module-option>
6.
<module-option name="rolesProperties">props/tomcat-statusroles.properties</module-option>
7.
</login-module>
8.
</authentication>
9.
</application-policy>
http://community.jboss.org/