How to Configure GitLab on Ubuntu?

how to configure gitlab on ubuntu

Configuring GitLab on Ubuntu is a very straightforward process, but getting the setup right is crucial to ensuring optimal performance and security whether you’re setting up GitLab for personal use or development and it gives super flexibility and control over your projects, so here we will discuss how to configure gitlab on ubuntu.

In this guide, we will let you know the step-by-step process of installing Gitlab on an Ubuntu server, with our detailed steps, you will be ready to run Gitlab on your Ubuntu server, enhancing your software development workflow with a fully functional, self-hosted version of this powerful platform. So Let’s start with the guide on how to configure Gitlab on Ubuntu.

What is GitLab?

GitLab is an open-source platform designed primarily for hosting Git repositories. It offers features like project management tools, continuous integration, and tracking issues. GitLab is a cloud-based Git repository and DevOps platform that offers an environment for testing, monitoring, and deploying their code.

It offers tools and features for managing Git repositories, continuous integration/continuous development (CI/CD), issue tracking, code review, etc.

Difference Between GitLab and GitHub

We already discussed Gitlab, so we can look into what GitHub is.

GitHub is an open-source version control system used to manage and track file modifications. GitHub can be used with any file type.

While GitLab and GitHub are among the most popular web-based Git repository hosting services, developers compare them due to their techniques for code repository management and hosting.

GitHubGitLab
It is a tool for managing repositoriesGitLab offers a free private repository with no limit
It is a service for hosting repositories with features for access control and collaboration.It is Less Secure compared to GitLab
You can choose your CI/CD tools after integrationGitLab comes with built-in CI/CD tools
Its is a service for hosting repositories with features for access control and collaboration.More Secure

Now let’s look at how to configure GitLab on Ubuntu,

How to Configure GitLab on Ubuntu

Follow the below steps to configure GitLab on the Ubuntu system:

Installing Dependencies

sudo su update

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

Installing GitLab

cd /tmp

curl -LO https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh

Select the internet site as the mail configuration type and press Ok. After that press okay to save the defaults.

less /tmp/script.deb.sh

sudo bash /tmp/script.deb.sh

sudo apt install gitlab-ce

Adjusting the Firewall Rules

You have to adjust the firewall rules for permissible to permit web traffic before configuring GitLab

sudo ufw status

sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH

Configuring the GitLab

sudo nano /etc/gitlab/gitlab.rb

locate the external_url and replace it with your domain and also ensure to change HTTP to HTTPS for redirection

...
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'https://your_domain'
...

sudo gitlab-ctl reconfigure

Initial Configuration using the Web Interface

First login into the server using your domain name

https://your_domain

It will generate the initial secure password for you, which is stored within a directory accessible to sudo users.

sudo nano /etc/gitlab/initial_root_password

# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the firs$
#          2.The password has not been manually changed, either through the user interface or the command line.
#
#         You should reset the admin password if the password displayed here does not work
https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
Password: YOUR_PASSWORD
# NOTE: This file will be deleted automatically during the first reconfigure run after 24 hours.

Use root as username and password listed on /etc/gitlab/initial_root_password in the login page and Sign-in.

Now you are all set!

Related Post:

>> How to Setup SFTP Server on Ubuntu – 9 Steps

>> Encoding and Decoding Using Base64 Strings in Python

Conclusion for How to Configure GitLab on Ubuntu

In this guide, we have covered how to configure Gitlab on Ubuntu, from installing dependencies to setting up a secure, self-hosted GitLab instance. By following these steps, you can easily manage your Git repositories, implement CI/CD pipelines, and enhance collaboration within your team.

With GitLab’s powerful features and a simple Ubuntu setup, you gain full control over your development environment, ensuring privacy and security. Now that you know how to configure GitLab on Ubuntu, you’re ready to boost your software development workflow with a fully functional, self-hosted solution.

For more advanced tips, always refer to the Official GitLab Documentation to stay up-to-date and secure.

Happy Development!

Leave a Comment

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.