How to host your own Git server on Linux

Hosting a traditional Git server on Linux for your programming code is a great idea, but the standard command-line only approach is very dated and lacking useful, modern features. These reasons alone are why so many projects end up on GitHub; it’s a low-cost, easy to use alternative to dealing with the hassle of command-line only Git.

GitHub is decent, but at the end of the day, it is a proprietary product owned by Microsoft. It also costs money. So, in 2019, if you want to have a Git server that houses all of your code, going with GitLab, the free, open-source competitor to GitHub is a no-brainer.

There are a whole host of reasons to use GitLab as the basis to your Git server on Linux, and costs are only part of it. It also offers up comparable features to GitHub, works with most GUI Git clients, has a great web bug tracker, and so much more!

Ubuntu Instructions

Setting up GitLab on Ubuntu starts by installing the necessary program dependencies, such as Curl, the OpenSSH server, Ca Certificates. You’ll also need to install the Postfix package for email notifications.

Note: the instructions in this section will work on Ubuntu 14.04 LTS, 16.04 LTS, and 18.04 LTS.

To start the dependency installation, enter the Apt command below into your Ubuntu machine’s command-line prompt.

sudo apt install curl openssh-server ca-certificates
sudo apt install postfix

After taking care of the dependencies for GitLab, it’s time to update Ubuntu to ensure that all the software on the system is up to date. This section is critical, so don’t skip it!

sudo apt update
sudo apt upgrade

Following the software upgrade, it’s time to start the GitLab installation. Use the curl command to grab the latest Ubuntu installation script.

curl | sudo bash

Let the script run. It should install everything required for GitLab to work on your Ubuntu system. When the script is complete, it’s time to configure the software to point to the correct domain.

In the terminal, enter the command below, but change the information after “EXTERNAL_URL” to the website URL you plan to access your GitLab server at.

sudo EXTERNAL_URL="" apt install gitlab-ee

Once the command above finishes, visit the URL that you set in the EXTERNAL_URL  section and use the username “root” to log in so that you may begin the post-installation configuration process.

For more information on how to configure and use GitLab on your Ubuntu system, visit the GitLab page on configuration.

Debian Instructions

Debian Linux has very similar installation instructions to Ubuntu because they are very similar operating systems. The process for setting up the software starts by using the Apt-get tool to install the dependencies (Curl, OpenSSH Server, Ca Certificates, and Postfix.)

Note: these instructions will work with Debian 8 and 9.

To start the dependency installation, enter the Apt-get command below into your Debian machine’s command-line prompt.

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

Following the dependency installation, use Apt-get to check for software updates. Do not skip this step!

sudo apt-get update
sudo apt-get upgrade -y

After the software is up to date, it is time to download the GitLab installation script with the curl command.

curl | sudo bash

Let the script download and run. While it’s in the process of running, the script will set up GitLab so that it’ll work on your Debian Linux system.

With the GitLab bash script done running, it’s time to configure GitLab’s URL. In the terminal, enter the EXTERNAL_URL command below. Be sure to change the example URL with the domain you plan to access GitLab at.

sudo EXTERNAL_URL="" apt-get install gitlab-ee

Assuming the EXTERNAL_URL command is successful, GitLab will be up and running on your Debian Linux system. To finish the setup process, open up a new browser tab at the URL you set for GitLab and use the username “root” to log in.

For more information on how to configure and use GitLab on Debian, visit the documentation page on the GitLab website.

CentOS 6 Instructions

Getting GitLab working on CentOS 6 is a simple process, and it starts by using the yum package manager to install the dependencies needed to run the software. The dependencies you’ll need are Curl, Policycoreutils-python, OpenSSH-Server, Postfix, and Cronie.

Note: these instructions also work with RHEL, Oracle Linux and Scientific Linux.

To start the dependency installation, enter the Yum command in the CentOS 6 command-line prompt.

sudo yum install -y curl policycoreutils-python openssh-server cronie

After Yum is done installing the above packages, use lokkit to allow HTTP and SSH through your system’s firewall.

sudo lokkit -s http -s ssh

Now that both HTTP and SSH are allowed through the CentoS 6 firewall, it’s time to use Yum to install the final GitLab dependency: Postfix.

sudo yum install postfix

Next, enable Postfix with the service and chkconfig commands.

sudo service postfix start
sudo chkconfig postfix on

Once Postfix is running on the system, use the curl command to download the CentOS installation script.

curl | sudo bash

Let the CentOS installation script run. As it executes, it’ll set everything up needed to get GitLab working on your system. When it’s done, use the EXTERNAL_URL command to point GitLab to the correct URL you want it to point to.

sudo EXTERNAL_URL="" yum -y install gitlab-ee

Following the installation, open up a new browser tab and visit the URL you set in the above command. Use the username “root” to log in.

For more information on how to configure and use GitLab on CentOS 6, visit the documentation page on the GitLab development website.

Related posts

5 Best VPN for Disney Plus

4 Mins read
One of the world’s most anticipated media streaming services is finally here. After being tested in the Netherlands for a short period…

8 Best Network Password Managers

9 Mins read
Password management tools will greatly reduce the amount of time that your IT support staff has to spend assisting users. Password management…

A visual guide for every Google Ads extension

3 Mins read
Sitelinks, the first Google ad extension, was introduced in 2009. They enabled advertisers to expand the total size of their text ads…

Leave a Reply

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