Gitlab on a Cloud Server
Introduction
Gitlab can serve as a central server for the git version control system. Additionally, it offers teams features for software project management, such as an integrated ticketing system and features for continuous integration and continuous delivery. Gitlab is comparable to github.com, but with the difference that it can be installed on a private server and you have full control as an administrator. Since it is offered as open-source software, specific adaptations to Gitlab would theoretically be possible.
The software primarily includes a web interface but also includes an integrated SSH server through which git clients can access repositories on the server. Developed in Ruby, Go, and Vue.js, Gitlab cannot be installed on a web space but runs on common Linux distributions, making its use on a Cloud server possible.
Gitlab is provided by the company Gitlab, Inc based in San Francisco, and it comes in two variants. A community edition “Gitlab CE” is available under an MIT Open Source license and can be used for free. If additional features not included in “Gitlab CE” are needed, one can turn to the paid “Gitlab EE” edition.
Prerequisites
Knowledge
This guide is intended for individuals with basic Linux knowledge, familiar with operating Linux servers. You should be able to manage the Linux command line and know how to connect to your Cloud server via SSH.
Hardware
Gitlab works with 4 GB of RAM, but a minimum of 8 GB is recommended. It is also recommended to have at least two CPU cores available. In this configuration, there are enough resources for about 100 users. The size of the disk space depends on the size of the git repositories that need to be stored on the server. For more details on the prerequisites for Gitlab, please refer to this page.
If backups of Gitlab are to be performed on the server itself, more storage space will be needed.
Operating System
This guide shows the installation on a newly configured Cloud server with Debian 10 “Buster”. Gitlab supports other Linux distributions. An overview of all this can be found on this page.
Domain
For the Gitlab server, you should create your own domain or subdomain, such as git.mustermann-domain.fr.
Installation
There are several methods to install Gitlab on a Debian system. Here we use the “Omnibus Gitlab” package. It allows the installation of the various components of Gitlab in a bundled form and avoids large complex configurations.
Please connect via SSH as the root user on your Cloud server:
ssh root@git.mustermann-domain.fr
and install the necessary dependencies with the following commands:
apt-get update
apt-get install -y curl sudo ca-certificates
Please add the Gitlab repository and install it with the following command:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Then install the gitlab-ce package for the community edition:
apt install gitlab-ce
After installing the package, the following message should appear on the screen:
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_./_/
Thank you for installing GitLab!
GitLab could not detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting the `external_url` parameter
in the /etc/gitlab/gitlab.rb file.
Then you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a complete list of configuration options, please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Configuration
After a successful installation, a few items still need to be configured before Gitlab can be used.
Please open the /etc/gitlab/gitlab.rb file with a text editor, such as nano or vim (for advanced users) on the server:
nano /etc/gitlab/gitlab.rb
Configuring a Correct URL
Please set the external_url parameter to the server’s URL, for example to https://git.mustermann-domain.fr. Please ensure to use https:// instead of http:// for a secure connection to the server. Gitlab automatically generates and uses an SSL/TLS certificate from “Let’s encrypt”.
## GitLab URL
##! URL on which GitLab will be accessible.
##! For more details on configuring external_url, see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://git.mustermann-domain.fr'
Please then run the following command to activate the new configuration:
sudo gitlab-ctl reconfigure
The operation will take some time. After many messages, the message “gitlab reconfigured!” should appear.
Configuring a Mail Server for Outgoing Emails (Optional)
In the /etc/gitlab/gitlab.rb file, you can enter the credentials for an external mail server if sending should not be done directly via the Gitlab server. The settings might look like the following:
### GitLab Mail Server Settings
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html
###! **Use smtp instead of sendmail/postfix.**
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "mail.mustermann-domain.fr"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "gitlab@mustermann-domain.fr"
gitlab_rails['smtp_password'] = "randompassword"
gitlab_rails['smtp_domain'] = "mustermann-domain.fr"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
Additionally, the sender’s address can also be specified:
### Email Settings
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'gitlab@mustermann-domain.fr'
Please then activate the new configuration:
sudo gitlab-ctl reconfigure
You can test sending emails later using, for example, the “Forgot Password” function of your user account.
Configuring the Administrator User Account
Please now access the page in your browser via the Gitlab instance URL. You will be able to set the administrator password there:

Then log in with the username “root” and the password you set:

After logging in, Gitlab appears as follows:

Since your name is probably not “root”, it is useful to change your username. This is done in your account settings. Please access it via the dropdown menu in the upper right corner of the page:

On the next page, you can, for example, change your display name and email address.

Then click on “Account” in the menu on the left, you can then change your username on the next page:

The interface language can be changed to German in “Preferences” for the individual user account:

Under “SSH Keys”, you can add a public SSH key to access Gitlab with git:

Disabling Public Registration
Gitlab generally allows anyone to create a new user account on the instance via the web interface. It is advisable to disable or restrict this feature. To do this, please access the “Admin” area:

Then click on “Settings” > “General” and expand the settings under “Sign-up Restrictions”:

Please uncheck “Sign-up enabled”. Instead of disabling registration, you can also, for example, only allow users with an email address from your company’s domain to register.
Creating User Accounts
New user accounts can be created in the “Admin” area. Click on “Overview” > “Users”:

To add a new user, click on “New User”:

Newly created users automatically receive an invitation link by email to set their password.
Backups
Since the Gitlab server generally contains critical company data, regular backups should be performed. Gitlab includes a backup tool in the Omnibus installation, which secures all important data of the installation. For this, the necessary dependencies must first be installed:
apt update
apt install tar rsync
Then a backup can be created on the server itself with the command:
gitlab-backup create
Backups are stored in the /var/opt/gitlab/backups/ directory as tar archives. Please copy the files from there to a secure location outside the server.
The backup does not contain the Gitlab installation configuration. However, it contains important cryptographic keys. Therefore, the configuration should be backed up separately. Please copy the directory
/etc/gitlab
to a safe location outside the server.
For more information on Gitlab backups and restoration, you can refer to the Gitlab documentation.
Updates and Maintenance
Gitlab continuously receives new features and, like any other software, errors and security vulnerabilities may have occurred during the development process, which can only be fixed by regularly installing updates. Since Gitlab was installed via the Debian package manager, updates for the Omnibus Gitlab installation will be automatically applied when updating the operating system with
apt update
apt upgrade
Other Features
Mattermost
The Gitlab installation directly includes the web-based instant messaging service for businesses “Mattermost”. How to easily configure Mattermost is described in the Gitlab documentation.
Large File Storage (LFS)
The Large File Storage" (LFS) extension for git allows managing large files economically in git. Git LFS does not store the entire version history on the client computer, but on the server, which is why Gitlab must support this feature. How to enable LFS in Gitlab is described here.
Continuous Integration, Continuous Delivery, and Continuous Deployment
“Continuous Integration” (CI) is a method in software development where small changes to software are automatically and independently tested during the development process and are only added to the codebase after a successful test.
“Continuous Delivery” and “Continuous Deployment” (CD) allow the semi-automatic or fully automated installation of the developed software on target systems.
Gitlab offers many features for CI and CD. You can find more information about this in the Gitlab documentation.
Conclusion
This tutorial has shown how to install Gitlab on a Cloud server and how to configure it in a basic way. It has also shown how to ensure secure operation through the installation of updates and the creation of long-term backups.
References
- Official site of the git version control system
- General information about Gitlab
- “Installing GitLab” in the Gitlab documentation
- “Configuration Options” in the Gitlab documentation
- “Backup and Restore GitLab” in the Gitlab documentation