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;

  1. 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
  2. Move the JDK directory to /usr/lib;
    sudo mkdir -p /usr/lib/jvm
    sudo mv ./jdk1.0.7.0_17 /usr/lib/jvm/jdk1.7.0
  3. 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
  4. 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;
wget http://www.atlassian.com/software/stash/downloads/binary/atlassian-stash-2.3.1.tar.gz

Note, the version I’ve listed there may not be the latest so you should grab it via here;
http://www.atlassian.com/software/stash/download

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.

 

2 Responses to Installing Atlassian Stash on a Headless Ubuntu Server

  1. K W says:

    Thank you very much for this. After flogging Gitolite around for a few days, I finally came to the realization that all I really needed to do was get Stash onto my Ubuntu Server box. This post was extremely helpful, especially with the Java crap. I should ask, though… why go through the FTP/SSH stuff at all, when we have wget?

Leave a Reply

%d bloggers like this: