Monday, November 16, 2009

JBoss 4 on CentOS 5

Following the step by step instructions to have JBoss 4 starting on boot on a CentOS 5 server.

1. create a jboss user with the command
useradd --system -d /your/jboss/root/dir jboss

2. copy the init script already available in the jboss distribution into the /etc/init.d folder with the command
cp /your/jboss/root/dir/bin/ /etc/init.d/jboss

3. alter the /etc/init.d/jboss file to match with the CentOS 5 SELinux distribution feature changing the line
  SUBIT="su - $JBOSS_USER -c "
to the equivalent SELinux of su
  SUBIT="runuser - $JBOSS_USER -c "

4. ensure the jboss user is capable of read and writing all the files in it's home folder executing the command
chown jboss.jboss /your/jboss/root/dir -Rf
chmod u+rw
/your/jboss/root/dir -Rf

5. (optional) ensure the deployers are capable of read and writing all the files in the jboss server dirs
chown jboss.devel /your/jboss/root/dir/server -Rf
chmod g+rws
/your/jboss/root/dir/server/ -Rf

6. (optional) ensure the jboss server is listening on the correct address specifing the -b option on startup changing the /etc/init.d/jboss script adding the bolded line (the non bolded line is placed as a positional reference):