Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setup for jboss 7 with apache and mod_cluster in ubuntu 11.10

Preparing Jboss environment

Create Jboss user and group

Create a group for a system user (daemnos and program users like www-data, mysql...)

# addgroup --system jboss

Create a user (system user, without home -> See below the command, to the jboss group and no login shell)

# useradd -r -M -g jboss -s /bin/false jboss

Maybe we want home to store data from maven, ant... that is needed by the jboss user when executing jenkins stuff

# useradd -r -g jboss -s /bin/false jboss

Add Jboss env var

Add to /etc/environment JBOSS_HOME var

#  echo "JBOSS_HOME=\"/usr/share/jboss7\"" >> /etc/environment

Installation of Jboss

Download Jboss 7 from [jboss donwnload site] ( Extract jboss in the proper place for example /usr/share

$ cd /usr/share
# tar xvf /home/xxxxx/Downloads/jboss-as-7.X.X.Final.tar.gz
# chown -R jboss:jboss /usr/share/jboss-as-7.X.X.Final/
# ln -s /usr/share/jboss-as-7.X.X.Final /usr/share/jboss7
# chown -h jboss:jboss /usr/share/jboss7

Installation of mod_cluster

Download the libs, [actually mod_cluster 1.1.3] ( Extract the libs

$ cd /home/xxxx/Downloads
$ mkdir ./mod_cluster_libs
$ cd ./mod_cluster_libs
$ tar xvf ./mod_cluster-1.1.3.Final-linux2-XXXX-so.tar.gz

Copy libs (not all,, and NO) to apache modules dir (i.e /usr/lib/apache2/modules/)

# cp ./  ./  ./  ./  /usr/lib/apache2/modules/

Configuration of mod_cluster in Jboss

Configure jboss Standalone mode to enable mod_cluster. Edit the standalone.xml file in $JBOSS_HOME/standalone/configuration/standalone.xml and add this two lines in their sections


<extension module=""/>


<subsystem xmlns="urn:jboss:domain:modcluster:1.0" />

Configuration of mod_cluster in apache

Create two files in mods-available (/etc/apache2/mods-available)


LoadModule proxy_module /usr/lib/apache2/modules/
LoadModule proxy_http_module /usr/lib/apache2/modules/
LoadModule proxy_ajp_module /usr/lib/apache2/modules/
LoadModule slotmem_module /usr/lib/apache2/modules/
LoadModule manager_module /usr/lib/apache2/modules/
LoadModule proxy_cluster_module /usr/lib/apache2/modules/
LoadModule advertise_module /usr/lib/apache2/modules/


CreateBalancers 1

<IfModule manager_module>
    ManagerBalancerName mycluster
        KeepAliveTimeout 300
        MaxKeepAliveRequests 0
        AdvertiseFrequency 5
        ServerAdvertise On
        <Location />
            Order deny,allow
            Allow from 127.0.0



And enable the module

# a2enmod mod_cluster

Configuration of jboss (mod_cluster/proxy) in apache

Create a file (virtual host) for jboss in sites-available (/etc/apache2/sites-available)


NameVirtualHost *:80
<VirtualHost *:80> 

    ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On
    ProxyPassReverse / balancer://mycluster
    ProxyPreserveHost On

    <Location />
        Order deny,allow
        Allow from All

   <Location /mod_cluster-manager>
      SetHandler mod_cluster-manager
      Order deny,allow
      #Deny from all
      Allow from 127.0.0


And enable the site

# a2ensite jboss

Fix mod_cluster log problem

There is a problem with mod_cluster (in ubuntu?), needs the log directory in /etc/apache2

We can do two things, create the dir or create a symbloic link to /var/log/apache2

Creating the dir

# mkdir /etc/apache2/logs

Creating the symbolic link

#ln -s /var/log/apache2 /etc/apache2/logs

Create Jboss daemon

Create a Daemon to start jboss as jboss user, so create aa file (/etc/init.d/jboss) with this content

# 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: Start/Stop JBoss AS v7.0.2
#source some script files in order to set and export environmental variables
#as well as add the appropriate executables to $PATH
#[ -r /etc/profile.d/ ] && . /etc/profile.d/
#[ -r /etc/profile.d/ ] && . /etc/profile.d/

case "$1" in
        echo "Starting JBoss AS 7.0.2"
        sudo -u jboss sh ${JBOSS_HOME}/bin/
        echo "Stopping JBoss AS 7.0.2"
        sudo -u jboss sh ${JBOSS_HOME}/bin/ --connect command=:shutdown
        echo "Usage: /etc/init.d/jboss {start|stop}"
        exit 1

exit 0

Install Jenkins

Download and deploy jenkins war

We download Jenkins from the [site] ( and we deploy the war.

Connect to the jboss admin console

# $JBOSS_HOME/bin/
$ connect
$ deploy /home/xxxx/Downloads/jenkins.war
$ exit

Configure jenkins environmnent

Create the jenkins home (data storage)

# mkdir /usr/share/jenkins
# chown jboss:jboss /usr/share/jenkins

Set env variable in java (the system vars sometimes doesn't work with jboss user from jboss-as). Edit servers boot conf (standalone, domain). For example for estandalone: Edit $JBOSS_HOME/bin/standalone.conf

Add in the end of the file:

#Set jenkins home env variable
JAVA_OPTS="$JAVA_OPTS -DJENKINS_HOME=/usr/share/jenkins"

This comment has been minimized.

Copy link

@ahoehn ahoehn commented Oct 7, 2012

Thanks for this good howto for mod_cluster. Unfortantly i don't get forwarded (when i access my servers url on port 80) to my jboss server (port 8080). Is there something else needed to get forwarded to jboss?


This comment has been minimized.

Copy link

@profversaggi profversaggi commented Nov 14, 2013

ahoehn, have a look at this article:

Evidently, the stock vintage of EAP 6 by default binds and connects to the IP address instead of the live one. By altering the standalone.xml and switching the live IP for the, it'll work just fine.

And a BIG thank you to the author for the awesome article, it saved my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.