If you need an inhouse git server and you have a small team only, then Stash from Atlassian might be something for you. We use it for several months now and I can say we are pretty happy with it.

Here’s how to install it on a Ubuntu 12.04 box:


Stash is running on Java, so you need to install a JRE. OpenJDK is supported.

~$ sudo aptitude install openjdk-7-jre-headless

Git is also needed, of course:

~$ sudo aptitude install git

You also need MySQL in case you want to run the database on the same server:

/srv$ sudo aptitude install mysql-server-5.5

Prepare User and Directories

Stash needs its own user, whose home directory is used as a data store. I therefore chosed to locate this directory under /srv/:

/srv$ sudo mkdir stash
/srv$ sudo /usr/sbin/useradd --create-home --home-dir /srv/stash --shell /bin/bash stash
/srv$ sudo chown stash:stash stash/

Install Files

I chosed to host installation in /opt/:

/opt$ sudo cp -a /home/claas/install/atlassian-stash-2.11.3
/opt$ sudo chown -R stash:stash atlassian-stash-2.11.3/


You need to tell Stash where its home directory is located. Add following line to /opt/atlassian-stash-2.11.3/bin/setenv.sh

set STASH_HOME=/srv/stash


Stash now already starts, but I noticed it listens on IPv6 ports only. To enable the regular IPv4 ports, open ``/opt/atlassian-stash-2.11.3/bin/setenv.sh` again and add the following parameter to the appropriate Java call:


Try Stash the First Time

Now, Stash is ready for a first try. Start it by

/opt/atlassian-stash-2.11.3/bin$ sudo -u stash -i /opt/atlassian-stash-2.11.3/bin/start-stash.sh

And open http://<your-server>:7990/setup to see if it’s working.

You can stop it by

/opt/atlassian-stash-2.11.3/bin$ sudo -u stash -i /opt/atlassian-stash-2.11.3/bin/stop-stash.sh

Automatic Startup

We want to have Stash being started automatically once the server is rebooted.

First, create a generic name for the application directory (this will upgrading to a newer version easier later on):

/opt$ sudo ln -s atlassian-stash-2.11.3 atlassian-stash-latest

Download the startup script provided by Atlassian and save it as /etc/init.d/stash. Adjust following lines to match our installation:

# Required-Start:    $remote_fs $syslog $mysql

And enable it via:

/etc/init.d$ sudo update-rc.d stash defaults
/etc/init.d$ sudo chmod +x /etc/init.d/stash

Finally, we need to set the JAVA_HOME environment variable. Add this line to ` /etc/environment`:


Install JDBC Driver

Stash doesn’t come with a JDBC driver, so you have to download this separately from the MySQL home page. Then, copy it to the stash installation directory:

/opt/atlassian-stash-latest/lib$ sudo cp /path/to/mysql-connector-java-5.1.29/mysql-connector-java-5.1.29-bin.jar .
/opt/atlassian-stash-latest/lib$ sudo chown stash:stash mysql-connector-java-5.1.29-bin.jar 

Prepare Database

Finally, you need to create a database for Stash:

mysql> SET GLOBAL storage_engine = 'InnoDB';
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON stash.* TO 'stash'@'localhost' IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> quit


These steps were enough to setup a basic Stash server for our needs. Check the manual for more installation options and details.