marți, 5 noiembrie 2013

How to set up JBoss AS (Application Server) on linux

This is a short step by step explanation of the setup of JBoss 7.0.2 on your Linux (explicit debian). Nowadays there is still no official Debian package for JBoss 7 out there, so we have to do a couple of steps manually.  First i describe how to download and to prepare the jboss. Secondly we do some basic configuration that you’ll be needed and at the end i will show you one of the ways to register JBoss as a service.

1. download and prepare.

Start by download  currently available version (7.0.2) of the JBoss 7.
#Web Profile version download.
Extracting files to the final location using tar.

tar zxvf jboss-as-web-7.0.2.Final.tar.gz -C /usr/local/
Now your JBoss 7 is placed inside /usr/local/jboss-as-web-7.0.2.Final/.I dont’t like that name.  It’s just cosmetics, but i prefer to rename the last part ot the path.
cd /usr/local/
mv jboss-as-web-7.0.2.Final/ jboss-7.0.2
Now important things. Some basic security and right management. I suppose  you don’t want to start your JBoss with root rights.
Therefore we need to create new user and new group named  jboss. Make them owner of your JBoss stuff.
addgroup jboss
useradd -g jboss jboss
chown -R jboss:jboss /usr/local/jboss-7.0.2/
Your jboss 7 is almost installed now.

2. Configuration and first test.

Start your brand new  Jboss 7 server with:
sudo -u jboss sh /usr/local/jboss-7.0.2/bin/ &
Now it  is testable on your local machine with http://localhost:8080.
But! maybe you trying to install that jboss on remote machine and want to access this installation remotely. I that case you need to enable remote interface of your JBoss. I assume we start by standalone configuration, so  you have to edit /usr/local/jboss-7.0.2/standalone/configuration/standalone.xml file. The easiest way is to  find  section and replace the address with 
   <interface name="management">
   <interface name="public">
Beware with this configuration you expose also the management console to the public. The console is bounded to interface named=”management” by default.  In production environments you have to put more attention to this. but now you can access your jboss from anywhere.

3. Jboss as Service

Now we have a basic configured JBoss, but i want to maintain it as a service. Unfortunately Jboss archive has no predefined init.d scripts, so i have to to it on my own. But this is not a big problem, just straightforward following some Debian conventions and useful scripts.
Ok, let’s create jboss maintenance script.
touch /etc/init.d/jboss
chmod 755 /etc/init.d/jboss
Ready! Now put following inside.
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Management of JBoss AS v7.x
#Defining JBOSS_HOME
case "$1" in
echo "Starting JBoss AS7..."
sudo -u jboss sh ${JBOSS_HOME}/bin/ &
echo "Stopping JBoss AS7..."
sudo -u jboss sh ${JBOSS_HOME}/bin/ --connect command=:shutdown
echo "Showing server.log..."
tail -1000f ${JBOSS_HOME}/standalone/log/server.log
echo "Usage: /etc/init.d/jboss {start|stop|log}"
exit 1
;; esac
exit 0
This file is ready to use. You can use it self for manual start and stop of your jboss, you also can follow the server.log by using “log” parameter.
But let’s make it to the end, as an automatic starting service. It’s easy with update-rc.d script:
update-rc.d jboss defaults
Now your ready and your JBoss will be shutdown on machine shutdown and it should start on machine start-up.
Of course this is not the only way to start using JBoss 7. Your ideas are welcome!

Niciun comentariu:

Trimiteți un comentariu