How To Set Up a Personal Gitlab Server

If you need version control for your projects, you want to host it yourself, but you don’t want to use barebones git, you can configure a Gitlab server to store all your code while providing easy access via a web interface.

Gitlab is like your own hosted Github

Gitlab is a hosted git service that works much like Github, with an interactive web panel to manage your projects and display the code. If you just want an alternative to Github, you can use their free online service, without configuring anything yourself.

Unlike Github, the community edition of Gitlab is open source and free for you to host on your own private server. There are no limits on the size or number of projects, which makes this solution ideal for people with large binary files too large for the 100 MB limit of Github.

Obviously, this requires you to pay for the server and storage space for hosting your files. If you already have a server, you can install Gitlab at the same time as your other processes, but it is quite resource intensive: Gitlab recommends 4 GB of RAM, and in our tests, it used about 2.8 GB. may be able to get away with less, but you may experience slowdowns when pushing code. When it comes to processor usage, Gitlab stayed below about 10% usage in our tests when sending and removing large projects.

One thing to note is that if you run it yourself, it is not a 100% backup. If your instance is finished, your data may be lost. Really, git itself should not be used as a backup tool, although it can be used as such with services like Github.

How to install

First you need to make sure that the dependencies for HTTPS are installed – openssh-server and ca-certificates. They are probably already, but if they are not, you will want to get them from your distribution’s package manager. For Debian-based systems like Ubuntu, it would be:

sudo apt-get install -y curl openssh-server ca-certificates

You will also want Postfix to be installed and configured so that Gitlab can send you emails:

sudo apt-get install -y postfix

It’s optional, but nice to have.

Then you will need to add the Gitlab repository:

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash

If you have a different package manager than apt, you go need a different script.

Then you can install Gitlab. You will have to pass your external URL as an argument at runtime apt-get install. It’s a good idea to put this on a subdomain like git.example.com, so Gitlab does not interfere with everything you have running.

sudo EXTERNAL_URL="https://git.example.com" apt-get install gitlab-ee

Make sure to mark this domain as HTTPS; Gitlab installs and manages LetsEncrypt certificates automatically and free of charge.

The installation will take a few minutes, but once the operation is complete, you will be returned to your standard prompt with a message telling you that Gitlab is installed.

At this point, you can log out of SSH, as the rest of the configuration will be in the browser. Head to your configured URL and you should see the following welcome screen. This page must be distributed via HTTPS, with a new certificate for the subdomain.

Enter a new master password for the Gitlab root account; note that this is not your account password, you will create an account after that.

Once the password is set, you will want to create an account. Since this is your personal server, you can have the username of your choice. Feel free to enter the four-letter username you always wanted. Put your email, create the account, then log out immediately.

You will want to log in to the root account and give administrator access to your personal account. Username will be rootand the password will be the master password that you set a few seconds ago. You should now see a key icon taking you to the Gitlab instance settings:

From there, you can change your instance settings, such as the configuration of your site’s title and icon. You can also manage users and lock account creation if you prefer. From the “users” tab, you can promote your personal account as an administrator and log out of the root account.

From there, you should have full access to Gitlab. If you’re collaborating on code, you can create a new group and create a project under that group (rather than your username).

Once your project is created, you can connect it to your local Git as you normally would. Make sure to add your SSH keys in your account settings, so you can push without entering your password every time.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.