How to Install GitLab on Ubuntu Server: Step-by-Step Guide

 

install GitLab on Ubuntu server

Introduction

GitLab is a web-based platform that provides a comprehensive set of tools for the entire software development lifecycle. It serves as a centralized hub for managing repositories, integrating tools, features for DevOps, project planning, code review, continuous integration/continuous deployment, issue tracking, security and monitoring.

GitLab offers flexibility in being hosted on the user’s infrastructure, providing more control and ownership of the data and environment. GitLab is an open-source application and offers a free version suitable for small and personal projects, and a premium plan is also available for advanced features. 


Prerequisites
   Minimum RAM 8 GB, Maximum for Better performance
   Storage 100 GB, storage requirement depends on your organization's team strength and workload
   Root User or non-root user with sudo Privileges

Step 1 - Installation of Dependencies

Dependencies are packages, modules or libraries installed to help the program run smoothly and efficiently. Sometimes dependencies are not installed automatically; these dependencies are essential before installing the actual program. We will install the dependencies using the Ubuntu default package repository.


Refresh the local package stack with this command
#sudo apt update

Now run the following command to install the dependencies for GitLab installation. Some of the dependencies may already be installed, but this command will install the remaining ones.

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



During the dependencies installation, it prompts for Postfix to select the mail server configuration. Select it according to your environment's needs and requirements.


Next, it will prompt for the mail name, same is the case. Select it according to your environment requirements and needs. If you have a mail server in your environment, then configure it properly as per your environment.


After selecting this, your dependencies installation is complete.

Step 2 - GitLab Installation

After dependencies installation next step is to install GitLab on the system. Now download the GitLab script for installation on your system. Just go to the directory where you want to download this script with the cd command.

#cd /opt


Now download the GitLab installation script to this directory with this command.


After downloading the script, it's time to run the script with this command. Sometimes this script throws an error OS is not supported, or not added to packagecloud.io. So, to remove this error, use these options as shown below in the command.

#sudo os=Ubuntu dist=trusty bash script.deb.sh


Basically, this script sets up the environment for GitLab on your system by checking the required dependencies and libraries before the installation of GitLab. As you can see from the final message, the repository is set up. Now follow the command to install GitLab on the system.

#sudo apt install gitlab-ce


You will see the message on this screen. Thanks for installing GitLab!

Step 3 - GitLab Configuration

Update the configuration file for application settings according to your environment and reconfigure it. Open the GitLab configuration file with your favorite editor. Nano is used here.

#sudo nano /etc/gitlab/gitlab.rb


Now search for the external_url line and change it according to your domain name and change the http to https to redirect the users automatically to the site protected by the Let’s encrypt certificate.



Next search for letsencrypt[ ‘contact_emails’] settings and provide the email address accordingly to be informed about any issues.  To enable this setting, remove the # at the start and write the email address.



Save the changes, press CTRL + X, then Y and enter. After making these changes in settings, run the reconfigure command.
#sudo gitlab-ctl reconfigure


This will reconfigure the GitLab with your provided information about external_url and contact_mail. After this you didn’t answer anything; this will complete it automatically with the given information.


Step 4 - Firewall Rule Adjustment

If you have configured a firewall to manage web traffic, then you must allow some ports to allow traffic of these ports. It is optional in case of test environment, but for the production environment, it is necessary.

Verify the status of your firewall by this command
#sudo ufw status

The firewall is active and now you can allow traffic of HTTP, HTTPS and OpenSSH on the firewall by following this.

#sudo ufw allow http
#sudo ufw allow https
#sudo ufw allow openssh
After allowing the rules, check the status of the firewall by the command
#sudo ufw status


Now your web traffic will not be blocked by the firewall.

Step 5 - Web Interface of GitLab and Initial Configuration
As the initial configuration is done and GitLab is ready to get its web interface.

First Login 

To access the interface, type the URL of GitLab in your browser as http://gitlab.seeklinux or the IP address of this host.


At first login, it will ask to set a new password as shown below.

Provide the new password and press the Change Your Password button, then a login screen will appear like this.

Just enter the username as root and provide the newly created password, and press sign in. As you can see below, we have successfully signed in to GitLab.

Now you can manage your GitLab instance.

Edit Profile
After the first login, you can edit your profile and set things accordingly. As shown below.

You can update your profile picture, change your password, set your emails, and manage your account.

Password Settings
Here you can change the password.


Change Name and Enable Two-Factor Authentication

Go to user settings, then Account, where you can change the user name and enable two-factor authentication to increase the account’s security. After changing the name, remember to log in with the new name.



All User Settings
This is the list of all user settings that can be changed according to need and requirement.


Step 6 - How to Start, Stop and Check the Status of GitLab
To start the GitLab service command is 
#sudo gitlab-ctl start

To check the status of whether GitLab is running or stopped command is 
#sudo gitlab-ctl status


To stop the GitLab service, the command is
#sudo gitlab-ctl stop


This step-by-step guide about GitLab installation and configuration helps you to set it up in your test or production environment. You can go into user settings one by one and change them, and customize them as per your requirement.

keep visiting seeklinux for more updates and information.

Post a Comment

Previous Post Next Post