GitLab is a free and open-source front-end Git repository with wiki and issue tracking. It allows you to host Git repositories on your own server and set up a DevOps platform.
In this guide, we will install GitLab CE (Community Edition) on a Debian 10 (Buster ) system.
Prerequisites
- An instance of Debian 10 server with SSH access.
- Minimum of 8 GB RAM
- 20GB of hard disk space
- A valid domain name pointed to the IP address of the server.
- User with sudo rights
(1) Update the system
Access your Debian server using SSH to update the package list on the system
$ sudo apt update
(2) Install GitLab dependencies
After the update is complete, install the required dependencies as shown below
$ sudo apt install ca-certificates curl openssh-server postfix
For Postfix mail server, make sure the mail configuration option is Internet Site
Next, provide the system mail name as shown and press ENTER
After that, the system will automatically complete the installation of all packages and their dependencies
(3) Install Gitlab CE
First download the repository script from GitLab to the /tmp directory as shown
$ cd /tmp
$ wget https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
After the download is complete, you need to execute the script as follows
$ sudo bash script.deb.sh
This will set up the GitLab repository, ready for installing GitLab
After completing the setup of the repository, execute the command to install GitLab CE as follows
$ sudo apt install gitlab-ce
When prompted, press Y and press ENTER to continue the installation
During the installation, you will be notified that GitLab has not been configured and that a valid hostname has not been configured
We will go further and make the necessary configuration
(4) Configure Gitlab
To tune our GitLab installation, you need to edit the github.rb file. Here we will use the vim editor to open the file.
To optimize your GitLab installation, you need to edit the github.rb file, we will use the vim editor to open the file
$ sudo vim /etc/gitlab/gitlab.rb
Search and locate the external_url parameter. Update the field to correspond to your domain as follows:
Search for and locate the external_url parameter, update the field to correspond to your domain name as shown below
external_url ‘http://domain.com’
In this example, using our test domain name as follows
external_url 'http://crazytechgeek.info'
Next, find the letsencrypt['contact_emails'] parameter and fill in your own email address, which will be used to receive the Let s Encrypt SSL certificate expiration reminder.
letsencrypt['contact_emails'] = ['[email protected]']
Finally, save the file and reconfigure the GitLab installation as follows
$ sudo gitlab-ctl reconfigure
The reconfiguration takes about 5 minutes, and when the configuration is complete, you should see the output of GitLab Reconfigured!
(5) Visit Gitlab
Access your domain name from a web browser as follows
http://domain.com
On your first visit, you will be presented with the login page below. Log in with root user credentials.
You will be asked to change your password
Once done, click on the Change Password option and press ENTER. It then leads you to the GitLab Dashboard as shown
(6) Use Let's Encrypt SSL security certificate
Let’s Encrypt is a free security certificate by Lets Encrypt
authority that allows you to secure your website. GitLab configuration
supports Let’s Encrypt and, in this step, we will configure our Gitlab
instance to use Let’s Encrypt SSL for secure connections.
Let's Encrypt is a free security certificate licensed by Let's Encrypt to encrypt your website. GitLab is configured to support Let s Encrypt, in this step we will configure our GitLab instance to use Let s Encrypt SSL for secure connections.
Edit the gitlab.rb file
$ sudo vim /etc/gitlab/gitlab.rb
Edit the following parameters:
letsencrypt['enable'] = true
letsencrypt['auto_renew'] = true
The first line allows configuration of Let s Encrypt, and the second line sets automatic renewal of certificates
Apart from that, you can also define the monthly auto-renew time and date as follows
letsencrypt['auto_renew_hour'] = 5
letsencrypt['auto_renew_day_of_month'] = "*/6"
Set URL to HTTPS protocol instead of HTTP protocol
external_url 'https://crazytechgeek.info'
Save the changes and exit the configuration file, run the following command again
$ sudo gitlab-ctl reconfigure
To verify that everything is going as planned, call the command
$ sudo gitlab-rake gitlab:check
Reload the browser, you can see that the Let's Encrypt SSL certificate has taken effect.