To provide the platform for a JEE environment, a JBoss application server and a PostgreSQL database will be installed and configured on the system.

Step 1 - Install JBoss Application Server

Relevant config files:

  • <JBOSS_HOME>/standalone/configuration/standalone.xml
  • /etc/environment

A separate jboss-user will be created, which will control the server. The server software is installed in his home directory. This encapsulation provides more flexibility and a higher level of security.

In this guide, i'll keep things as simple as needed, for further information consult the JBoss getting started guide.

Prepare environment

Set up a new user called jboss:

root@jiffybox # useradd -d /home/jboss -m jboss
root@jiffybox # usermod -a -G jboss
root@jiffybox # chsh jboss # set default shell (i used /bin/zsh)
root@jiffybox # chown jboss:jboss -R /home/jboss # to be sure

Install the software.

Change to jboss home dir, then download and unpack the installation archive:

jboss@jiffybox # cd /home/jboss
jboss@jiffybox # wget "http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz"
jboss@jiffybox # tar -xvf "jboss-as-7.1.1.Final.tar.gz"
jboss@jiffybox # ln -s jboss-as-7.1.1.Final jboss # use a link to refer to jboss
jboss@jiffybox # chmod o-rwx -R .
jboss@jiffybox # chmod g-w -R .

Finish the installation

Set the JBOSS_HOME environment variable in your system:

root@jiffybox # vim /etc/environment
Add the line to the config file /etc/environment
JBOSS_HOME=/home/jboss/jboss
I referred to the symlink here.
Note, a system restart may be required due to the environment change.

Start server and test installation.

jboss@jiffybox # cd /home/jboss/jboss/bin/
jboss@jiffybox # sh standalone.sh &
jboss@jiffybox # wget localhost:9990 -O - # check if you get a start page

Setup connectivity to external hosts

At first, we need an user to login to the jboss management console in the browser.
Start the jboss util script and follow the instructions:

jboss@jiffybox # cd /home/jboss/jboss/bin/
jboss@jiffybox # ./add-user.sh

Edit the /home/jboss/jboss/standalone/configuration/standalone.xml and insert the "any-address" tags as listed:

<interfaces>
    <interface name="management">
        <!--<inet-address value="${jboss.bind.address.management:127.0.0.1}"/> -->
        <any-address/>
    </interface>
    <interface name="public">
        <!--<inet-address value="${jboss.bind.address:127.0.0.1}"/> -->
        <any-address/>
    </interface>
    <interface name="unsecure">
        <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
    </interface>
</interfaces>

Increase convenience

I created some handy shell-aliases to control the server with more comfort.
Those are added to the jboss-user's /home/jboss/.zshrc script:

PATH="$PATH:/home/jboss/jboss/bin"
alias killjboss='ps auxwww | grep -E "(org\.jboss|8080)" | awk '"'"'{print $2}'"'"' | xargs kill -9'
alias startjboss='~/jboss/bin/standalone.sh > ~/jboss-standalone.out 2> ~/jboss-standaone.err & ; tail -F jboss-standalone.{out,err}'

Now start jboss by typing

jboss@jiffybox $ startjboss # (or use the following commands:)
jboss@jiffybox $ ~/jboss/bin/standalone.sh > ~/jboss-standalone.out 2> ~/jboss-standaone.err &
jboss@jiffybox $ tail -F jboss-standalone.{out,err}
Done, you should now be able to login with the created user to the JBoss Admin Console

Step 2 - Install PostgreSQL database server

Relevant config files:

  • etc/postgresql/8.4/main/postgresql.conf
  • /etc/phppgadmin/apache.conf
  • /etc/apache2/conf.d/ (a link will be created here)
  • /etc/apache2/apache.conf (a link will be created here)

A separate postgresql-user will be created, who will control the server. This encapsulation provides more flexibility and a higher level of security.

Install the server software

PostgreSQL is available as a Ubuntu package, simply install it:

root@jiffybox # apt-get install postgresql
A user called postgres is created during installation.

Setup an user and an example database

The postgres user is used to create db users and databases.

root@jiffybox # su - postgres
postgres@jiffybox $ createuser andre -P
postgres@jiffybox $ createdb andretest1 -O andre
postgres@jiffybox $ exit
root@jiffybox # su - andre
andre@jiffybox $ psql andretest1 # a psql terminal will open.
andretest1=> create table test (a integer);
andretest1=> insert into test (a) values (1), (2);
andretest1=> select * from test;
andretest1=> drop table test;
Start the server to apply the configuration changes:
root@jiffybox # /etc/init.d/postgresql-8.4 restart

Enable remote connections (if needed)

If you need to access your database from an external host, change your /etc/postgresql/8.4/main/postgresql.conf as described below.
Note, you need to enable remote access for each user and database.

# listen to hosts outside (generally).
listen_addresses = '*'
# grant remote connections to db 'andretest1' for user andre
host andretest1 andre 0.0.0.0/0 md5
Restart the server to apply the configuration changes:
root@jiffybox # /etc/init.d/postgresql-8.4 restart

Install Phppgadmin (optional)

Phppgadmin is a web based console for postgresql backends, similar to PhpMyAdmin. If you do not need it, you can omit this step.
This software is also available as a Ubuntu package:

root@jiffybox # apt-get install phppgadmin
Note, the installation of phppgadmin automatically links /etc/phppgadmin/apache.conf into /etc/apache2/conf.d/.
Therefore no include statement is needed in in /etc/apache2/apache.conf like in the PhpMyAdmin installation manual.

We want to access this Web-Gui from other hosts so,
edit the /etc/phppgadmin/apache.conf and change this value:

allow from all

Done, after a server restart (due to the changes in the apache config) with

root@jiffybox # services restart apache2
you should be able to login to Phppgadmin.