This short tutorial describes how to configure JBoss Application Server (Jboss GA 5.1.0) on a debian linux (Debian GNU/Linux 5.x “Lenny” ). Article starts with installation of java JDK and continues with JBoss installation and basic configuration according to standard file system hierarchy. Also init.d. scripts configuration is given here.
Installing Java SDK
Nowadays installing Java environment on Debian is an easy task. I used JDK 1.6. Don’t confound JDK with JRE, because bare Java Runtime Environment is not enough for running JBoss. Debian Wiki maintains (hope) a list of available java .deb packages, which are easily can be installed with your preferred way. I prefer aptitude, but apt-get of course works too.
$ aptitude install sun-java6-jdk #or by good old apt-get. $ apt-get install sun-java6-jdk
Installation is done after seconds. Now test your java installation with
$ java -version # Here example result on my configuration: java version "1.6.0_12" Java(TM) SE Runtime Environment (build 1.6.0_12-b04) Java HotSpot(TM) 64-Bit Server VM (build 11.2-b01, mixed mode)
If you get something like this, you’re done and your java should be already in the PATH.
Installing JBoss AS
Now let’s install JBoss Application Server.
Normally you are not willing to start services (especially when they are accessed from outher machines) with root privileges. Therefore we have to define new user and group which will be used to manage JBoss. So next line will create new group and new user with this group.
$ groupadd jboss $ useradd -s /bin/bash -d /home/jboss -m -g jboss jboss
This jboss user has no password, so nobody can login with this username. If you consider to login with jboss user, password has to be set. Use passwd jboss command for that.
Download, Installation, filesystem layout
Now download desired Jboss version. I started with JBoss 5.1.0 GA, which can be download with:
$ cd /tmp # swithch to temp dir $ wget http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA.zip/download
Check also the whole list of verisons if interested. As you may noticed JBoss binaries are packaged with ZIP. So it is comfortable to use unzip tool. Maybe you have to install it first.
But before you extract downloaded file, we have to decide, where exactly should JBoss files be placed on a file-system. Unfortunately JBoss is not quite conform to Linux File System Hierarchy Standard per default, so there are many possibilities for a location configuration. Some of you may want to place JBoss into /opt directory. But I prefer to split the installation a little bit and want to start by putting JBoss core files in /usr/local/, where local, unchangeable and read-only files usually placed. E.g. I use /usr/local/jboss/510 as JBoss 5.1.0 GA root. So let’s create that location and extract files into it.
mkdir /usr/local/jboss #create new jboss directroy chown jboss:jboss /usr/local/jboss #now its belongs touser jboss and group jboss su jboss mkdir /usr/local/jboss/510 cd /usr/local/jboss/510 unzip /tmp/jboss-5.1.0.GA.zip
At this moment you should have new working JBoss. If you want, test it with
bin/run.sh -b 0.0.0.0
Where -b 0.0.0.0 means that JBoss is listening for every ip address of current machine.
However at this stage the installed Jboss still brakes the Linux Filesystem Hierarchy Standard, so let’s improve this situation.
After the first start of the server used configuration will have new directories /tmp and /work . The /tmp directory contain the temporarily state of the deployed applications and /work is contains compiled jsp pages of deployed applications. Therefore both directories are of temporal character and should be on more appropriate place according to Linux standards.
I use only a default JBoss configuration, which is defined under <jboss_root>/server/default, so I need to do further changes only for this configuration. My decision is to put both directories to /var /tmp/jboss.:
$ mkdir /var/tmp/jboss $ chown jboss:jboss /var/tmp/jboss/ $ su jboss $ mkdir /var/tmp/jboss/510 $ mkdir /var/tmp/jboss/510/tmp # creating alternavtive location for tmp $ mkdir /var/tmp/jboss/510/work # creating alternavtive location for work $ cd /usr/local/jboss/510/server/default # switch to configuration directory if not allready here. $ rm -R tmp # delete existing tmp directory (server should not run at this moment) $ rm -R work # delete existing work directory $ ln -s /var/tmp/jboss/510/tmp ./tmp # Finaly create symbolic link to new place$ $ ln -s /var/tmp/jboss/510/work ./work # Finaly create symbolic link to new place
repeat the same for /log directory. It is common to have logs at one place in /var/log
create a log directory tree e.g. /var/log/jboss/510/ and let log link to it as was shown for tmp and work directories.
After that your configuration directory should look like:
$ ls -l /usr/local/jboss/510/server/default drwxr-xr-x 6 jboss jboss 4096 22. Mai 2009 conf drwxr-xr-x 6 jboss jboss 4096 23. Jan 00:10 data drwxr-xr-x 15 jboss jboss 4096 22. Mai 2009 deploy drwxr-xr-x 12 jboss jboss 4096 22. Mai 2009 deployers drwxr-xr-x 2 jboss jboss 4096 22. Mai 2009 lib lrwxrwxrwx 1 jboss jboss 19 23. Jan 01:07 log -> /var/log/jboss/510/ lrwxrwxrwx 1 jboss jboss 23 23. Jan 01:13 tmp -> /var/tmp/jboss/510/tmp/ lrwxrwxrwx 1 jboss jboss 24 23. Jan 01:13 work -> /var/tmp/jboss/510/work/
And your logs are of course accessible directly at new location e.g.
tail -1000f /var/log/jboss/510/server.log
Furthermore you should deploy your applications to /srv/jboss/510 to enable this location for automatically scan and deployment,just create a link from /default/deploy/. Call it e.g. applications.:
$ ln -s /srv/jboss/510 ./usr/local/jboss/510/server/default/deploy/applications #
So applications which are placed to /srv/jboss/510 will be automatically deployed on the server.
Start JBoss on boot
First of all you need a life-cycle management script used by init. Jboss already provides some of then. Let’s use one of Red Hat default script by adopting it a little bit. First of all copy the script to common place (feel free to ad version ti scriptname if you need or like)
$ cp /usr/local/jboss/bin/jboss_init_redhat.sh /etc/init.d/jboss
If you want to access you fresh JBoss also from other IP addresses you need to change
JBOSS_HOST line according to:
0.0.0.0. binds it on all IP addresses. Consider to change also other param this file to mach your personal needs. Now you can automatically create all the symbolic links used by init service.
$ update-rc.d jboss defaults
Now your Jboss will start automatically after reboot…
- <jboss_root>/bin/run.conf file configures the start parameters of the server. Maybe default limits are not suitable for your applications. So check it.
- Under <jboss_root>/server/default/conf you will find some configuration files of the default server configuration. One of the interesting is of course jboss-lo4j.xml, where you can precisely define logging processing.
Questions & Suggestions
Thank you for reading this. Please feel free to provide any suggestions to the topic of JBoss installation on Linux and specially on Debian. Of course your questions are welcome too!