Last Updated: February 25, 2016
· hendrikpetertje

Setup Your own Gitlab server from the on-click install image (Digital Ocean)

Do you want to host your very own Git remote with a front-end html website? Good news! The guys over at GitlabHQ created the perfect web-app. Digital ocean has a one click application droplet that will save you a bucket of installations, clones and what not, but even plug-and-play needs configuration of course. This tutorial will help you setup the server.

Create the server image

Login to Digital Ocean and create click the "New Droplet" button.
In the page fill out the details for your new droplet. The best thing is to choose $10.- server since this server has the necessary RAM of 1GB. You can however choose for the $5.- server to but this will require setting up Swap once your server is deployed.
Now when selecting your image choose "Application" and select GitLab.
Create the droplet and wait for your ssh keys to come in.

Modify the Ubuntu environment.

Change login details

Log in to your root account using your version of the command below

ssh root@your-servers-ip

Fill out the password you received by mail.
If you logged in successfully at this point, the best thing to now is change that long and boring password to something you can actually remember. type the command below and create a new password for the current user:


now exit the server connection (by typing exit) and try to connect again using your new password.

Auto login using SSH-keys

At this point you don't want to waste time filling out that password everytime you connect. Best thing to do would be to add your SSH credentials to the root user.

on your local machine (not connected to your server) create ssh keys as described in this tutorial
Now request the public key using the command below:

cat ~/.ssh/

copy the key to your clipboard using [ctrl]+[shift]+[c] (linux) or [CMND]+[C] (Mac)
In windows copy the key, past it in a document and remove all the enters that your command prompt somehow created.

login to your server using the ssh command and type the commands below:

cd ~/.ssh
nano authorized_keys

This will open an empty document in the terminal. Paste the key you copied to your clipboard and save the document. When login in to your server again you are not asked for your password anymore :)


When creating the server with either 500mb RAM or 1GB, there's going to be a need for a little bit more virtual memory at some point. You need to create a Swap file on the server. This way a portion of disk space will be used as virtual memory for the computer.

Give the command below while being root user:

fallocate -l 1024M /mnt/swap.img
mkswap /mnt/swap.img
swapon /mnt/swap.img

Now tell the server to load the swap file by adding the line below to /etc/fstab

/mnt/swap.img  none  swap  sw  0 0

Setup the GitLab application

Alter basic settings

GitLab shell

GitLab Shell is an SSH component for GitLab. Open the GitLab shell configuration file with your text editor:

nano /home/git/gitlab-shell/config.yml

Adjust the gitlab_url parameter to match your domain name. As the comment in the file says, your URL should end with a slash:

gitlab_url: ""

Save and close the file.

Main configuration

Next, open the main GitLab configuration file with your text editor:

nano /home/git/gitlab/config/gitlab.yml

In the gitlab: section, find and adjust the host: parameter to match your domain name:

  ## Web server settings
  port: 80
  https: false

While you're in this file, you can adjust the email settings that GitLab will use in the "From:" field in automated emails, and the email published for support contact, respectively:


Save and close the file.

Now, you just need to restart the service:

service gitlab restart

Reset the Gitlab Environment

A lot of users notice errors when trying to connect to the Git user using push, pull and clone commands. This is because in most cases the Gitlab shell needs reconfiguration before it works.

The command below will rest all gitLab-keys that could still be hanging around in the basic Linux Environment

cd /bin
./bin/gitlab-keys clear

The command below will drop the gitlab-shell database, create it again and populate it with the right migrations (don't forget the sudo command here since we're going to give it parameters).

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production

Now restart the server to reload all scripts, environments and stuff.

shutdown -r 0


If you still have some time update the ubuntu server environment using the command below:

apt-get update && apt-get upgrade && apt-get dist-upgrade
shutdown -r 0

To monitor your servers usage install the htop application using the command below:

apt-get intall htop

And open the application using


First login

open a browser and navigate to your new website
login using the following credentials:

Password: 5iveL!fe

The website will ask you to change your password. Change the password. When you are done doing that navigate to your profile settings and change your e-mail adress and full name.

Now create nice repo's and get going!

Good luck!