GitLab is a open DevOps platform, delivered as a single application. A benefit from this application is that you can self-host it on your infrastructure on a VPS server. GitLab also provides our teams a single data store, one user interface, and one permission model across the DevOps lifecycle allowing teams to collaborate that would significantly reduce cycle time and focus exclusively on building great software quickly.
In this tutorial, we’ll show you how to self-host a GitLab Instance using Debian 10.
Prerequisites
- A VPS server with at least 8 GB ram and 4 CPU Cores, as per GitLab Recommendation.
- Root access on your server
- Basic SSH knowledge
Installation
First of all, we need to login into the SSH from your server.
ssh root@server_ip
Then, we need to stop the apache2 service if it’s up and running, by disabling and deactivating it permanently since our GitLab will install Nginx:
systemctl stop apache2
systemctl disable apache2
After removing them, we’ll proceed with the system update and installation of the dependencies.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt -y install curl vim openssh-server ca-certificates
Next, we need to install postfix, it will be responsible for the email sending from the application.
If you want to use another solution to send emails please skip this step and configure an external SMTP server after GitLab has been installed.
apt-get install postfix -y
During Postfix installation a configuration screen may appear. Select ‘Internet Site’ and press enter. Use your server’s external DNS for ‘mail name’ and press enter. If additional screens appear, continue to press enter to accept the defaults. You can take a look at our PostFix installation guide.
Then, with all dependencies installed, we’ll need only to add the package from Gitlab on your server with the following command:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
With this package added, we need to install the gitlab instance on our domain. On this step, please consider pointing one domain or subdomain to your VPS server. You can use gitlab.yourdomain or whatever subdomain do you want. It just needs to be pointed and propagated to your VPS, because we’ll require this propagation to install the SSL and access our instance later.
When you choose your subdomain, you need to run the following command on your SSH session to install the gitlab:
sudo EXTERNAL_URL="https://gitlabtest.rosehostingtest.com" apt install gitlab-ce
Make sure to change the EXTERNAL_URL=”https://gitlab.example.com” to match your subdomain.
Before we proceed with all, you’ll need to enable Let’s Encrypt on your gitlab instance. Please edit the Let’s Encrypt section from the file /etc/gitlab/gitlab.rb to match the following:
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com'] # This should be an array of email addresses to add as contacts
letsencrypt['auto_renew'] = true
Also, if you want to auto renew this SSL certificate, please edit the following sentences to match this, on the same file:
letsencrypt['auto_renew_hour'] = 3
letsencrypt['auto_renew_day_of_month'] = "*/7"
After editing and saving this file, run this command to reconfigure the gitlab instance:
gitlab-ctl reconfigure
Once the installation finishes, your instance will be up and running and you can access it by typing your hostname. When you first access it a username and password will be requested. You can get the admin default password on the following file (/etc/gitlab/initial_root_password
) as shown below:
You just need to copy this password and fill on the gitlab page with the user root.
And we are done, you successfully installed your gitlab community instance and can use it with your custom hostname as shown below:
And your installation is done, you can use your gitlab normally. There are some recommended configuration steps to apply in your instance.
Also, you can access the admin page on the Menu at the top and then Admin. There you can create new users and configure your gitlab instance.
And that’s it, GitLab has been successfully installed and running on your Debian 10 server, you and your team can start working with it now.
Of course, you don’t have to install GitLab on Debian 10 if you have a Debian VPS Hosting with us. You can simply ask our support team to install GitLab on Debian 10 for you. They are available 24/7 and will be able to help you with the installation of GitLab on Debian 10.
PS. If you enjoy reading this blog post on How to Install GitLab on Debian 10, feel free to share it on social networks using the shortcuts below, or simply leave a comment.