Today’s post relates to my experience installing Atlassian Stash on a headless Ubuntu box. My first attempt ended with me trying all sorts of nonsense which left the server messy as hell, including an accidental installation of Unity…
The trickiest part for me was the installation of Java as the version available via the package manager, OpenJDK, didn’t seem to play ball with Stash. No idea why but one of the helpful fellows from Atlassian, Stefan Saasen, pointed me in the right direction with this article which I’ve used as basis for the steps below, the browser plugin steps were omitted for obvious reasons.
First of all you need to grab the tar file for Java from here then get it onto your server, the easiest way I found was to use an FTP application in SSH file transfer mode. Then connect to the terminal and run through these commands;
- Decompress the tar file noting that the file name will reflect the version you download and may differ from mine;
tar -xvf jdk-7u2-linux-x64.tar.gx
- Move the JDK directory to /usr/lib;
sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk126.96.36.199_17 /usr/lib/jvm/jdk1.7.0
- Now run these lines, no idea why, explanation in the comments please!
sudo update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/jdk1.7.0/bin/java” 1
sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/lib/jvm/jdk1.7.0/bin/javac” 1
sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/lib/jvm/jdk1.7.0/bin/javaws” 1
- Correct the permissions for the executables;
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
If you are installing on a fresh server, that should be all you need for Java to work. If you’ve a few JVMs present on your machine, see the original article for steps to configure the default. For Stash, you can now follow the instructions here. One thing I found quite useful was the wget command that a colleague showed me, it makes downloading via the terminal quite easy, getting the Stash installer for example can be done like so;
Note, the version I’ve listed there may not be the latest so you should grab it via here;
For editing the setenv.sh file, and text files in general, I’ve found nano really useful. I’ve not ventured into the murky depths of the text editor holy war yet but this does the trick for now. I had to run the same chmod against the Stash home directory I created but after that I was good to go. Open a browser to the path listed in the console and use the wizard to continue setup.