Installing JBoss Application Server isn’t easy – it’s big, clunky and documented by sexually frustrated neckbeard types who write like wannabe MIT professors. As a predominantly PHP-based developer, and Ubuntu user (i.e. one of the “unwashed masses”) this can be a bit daunting, if not outright fucking frustrating, especially because JBoss-types snob us Ubuntu types.
For this reason, I’ve compiled a guide on installing JBoss on Ubuntu Server 11.04 (this guide works fine for the desktop version of Ubuntu as well).
Preperation
First, we need to create a user that will run JBoss on your Ubuntu server – lots of services do this, like Apache is usually ran as a user called “www-data”.
$ sudo useradd -m -d /usr/local/jboss -s /bin/sh jboss
Now we need to install a Java Development Kit. For the purposes of this tutorial I’m using the Sun one, but there’s a bunch of others that exist because some other neckbeard types don’t like the Sun license.
The Sun JDK package is sun-java6-jdk, but to get access to it through apt, you have to uncomment the ‘partner’ repositories in /etc/apt/sources.list, so open that file up in nano or something and uncomment the following two lines (they’ll be near the bottom)
deb http://archive.canonical.com/ubuntu natty partner
deb-src http://archive.canonical.com/ubuntu natty partner
Once that’s done, you’ll need to update the GPG signatures on the repositories and update apt.
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 3E5C1192 && sudo apt-get update
Now you can finally install the Sun JDK
sudo apt-get install sun-java6-jdk
It probably wants to restart, so you’d better let it.
Downloading
Now we need to download JBoss – sounds easy, but there’s so many different download links on the JBoss download page that I could forgive a person for not knowing. You want to click the one that says 6.0.0.Final, and once you’ve done that, download the one that looks like jboss-as-distribution-6.0.0.Final.zip. The easiest way to do this is to just fetch it with the command
$ wget -O ~/jboss-as-distribution-6.0.0.Final.zip http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/jboss-as-distribution-6.0.0.Final.zip/download
Now we can unzip it to the place JBoss recommends – /usr/local
$ sudo unzip ~/jboss-as-distribution-6.0.0.Final.zip -d /usr/local/
This will make the directory /usr/local/jboss-6.0.0.Final, which we need to do two things to: first, set its owner as that jboss user we made earlier
$ sudo chown -R jboss:jboss /usr/local/jboss-6.0.0.Final/
Second, create a simlink to it from where JBoss will expect it to be – /usr/local/jboss (deleting the actual directory first – thanks Ken)
$ sudo rm -rf /usr/local/jboss
$ sudo ln -s /usr/local/jboss-6.0.0.Final /usr/local/jboss
This is just another “best practice” thing to do, and can make upgrading/downgrading less of a hassle in the future.
Setting up service scripts
JBoss comes out of the box with service scripts (those things that live in /etc/init.d) for RedHat, SUSE, CentOS, Solaris, HPUX (whatever the fuck that is), but not Ubuntu – another serious case of neckbeard snobbery. So let’s make one.
First, copy the RedHat script and rename it ‘ubuntu’
$ sudo cp /usr/local/jboss/bin/jboss_init_redhat.sh /usr/local/jboss/bin/jboss_init_ubuntu.sh
Now open it up in your favourite text editor (I use nano – fuck you neckbeards), and make the following amendments
- Change the JAVAPTH line so it points to just /usr/bin
JAVAPTH=${JAVAPTH:-"/usr/bin"}
- Between the JBOSS_CONF and JBOSS_BIND_ADDR lines, add a definition for JBOSS_HOST, because if you don’t JBoss “binds” to the loopback interface and you can only access it from the server itself – nice one neckbeards. You can make this line either lots of zeros, which is like a wild-card, or a specific IP address if you only want it to be accessible from a particular network interface. Personally I believe this sort of shit is the responsibility of your firewall, and consider this sort of config totally redundant.
JBOSS_HOST=${JBOSS_HOST:-"0.0.0.0"}
Once you’ve saved it, we can now make a simlink to it from /etc/init.d
$ sudo ln -s /usr/local/jboss/bin/jboss_init_ubuntu.sh /etc/init.d/jboss
Finally, let’s add it to the system startup services, so it will run at boot (like Apache and all those kind of services do)
$ sudo update-rc.d jboss defaults
Now you can actually try firing the bitch up now by running the following command
$ sudo /etc/init.d/jboss start
On my crappy VM it takes about a minute, and it doesn’t tell you when it’s “done”, so you can follow it’s progress by seeing which ports it’s opened with the following command
$ netstat -al
You’re looking for one with :http-alt in the line. As soon as that’s up, you’re good to go.