How to Install Gitlab Self Hosted Server on Ubuntu 20.04 Tutorial

Install Gitlab Self Hosted Server on Ubuntu 20.04. GitLab is a free, open-source code repository used for the software development process, issue tracking, and CI/CD by DevOps. The open-source code repository was initially created by Valery Sizov and Dmitry Zaporozhets. It began as an open-source project in 2011. But, later was converted and used by businesses to support the software development lifecycle. Written in Ruby and Go language, the platform provides end-to-end DevOps capabilities. Also, many tech companies like IBM, Sony, Cisco, Juniper, Oracle, etc., rely on it.

What is GitLab?

GitLab is a service that provides remote access to Git repositories.  GitLab self-hosted in addition to  hosting your code it also provides additional features , such as issue tracking, code reviews and activity feeds.  Gitlab acts as a central hub to create, store, deploy, and collaborate all web-based projects. One can create private and public GitLab projects as per their need. 

 

GitLab CI/CD on-premise and connect it with Active Directory and LDAP servers for secure authorization and authentication.  The majority of the front-end user experience is powered by Ruby on Rails running behind a web server, which starts the tasks via a jobs pool on a Redis server.

Features of GitLab

GitLab can burndown charts, set road maps, fix chat management issues, and other software development processes using the below-listed features. Have a look at some of the key features of GitLab:

  • Access Controls
  • User Permissions
  • Collaboration Tools
  • Project Management
  • Deployment Management
  • Customizable Templates
  • Easy to maintain repository on a server
  •  Supports Time Tracking, Issue tracker, Group Milestones for the development process
  • Spontaneous User interface
  • Continuous integration/continuous development pipelines
  • Supports container registry that involves deployment without configuration
  • Automates building and testing code
  • Management of Docker images using third-party servers
  • Supports Kubernetes integration
  • Supports integrated monitoring for applications and servers
  • Grouping and managing multiple Issue Boards
  • Supports merging, assigning, and closing of confidential issues
  • Supports debugging of containers
  • Load balancing of servers and applications
  • Multiple Kubernetes cluster support

In this post, we will show you how to install GitLab self hosted server on Ubuntu 20.04.

Add the GitLab CE Repository

By default, the GitLab package is not included in the Ubuntu default repository. So you will need to add the GitLab official repository to your system.

First, install the required packages with the following command:

				
					apt-get install curl ca-certificates -y
				
			

Next, download and execute the following script to add the GitLab repository to APT.

				
					curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash
				
			

Once the repository is added, you can verify it using the following command:

				
					cat /etc/apt/sources.list.d/gitlab_gitlab-ce.list 
				
			

You will get the following output:

				
					# this file was generated by packages.gitlab.com for
# the repository at https://packages.gitlab.com/gitlab/gitlab-ce

deb https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main

				
			

How to Install GitLab Self Hosted Server on Ubuntu 20.04

Install Gitlab Self Hosted Server on Ubuntu 20.04. To update the GitLab repository  you can achieve this by running the following command:

				
					apt-get update -y
				
			

Once the repository is added, install the GitLab community edition by running the following command:

				
					apt-get install gitlab-ce -y
				
			

Once the GitLab is installed, you will get the following output:

				
					
       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-6

				
			

Configure GitLab Self Hosted Server

At this point, GitLab is installed. Now, you will need to edit the GitLab configuration file and set your domain name for the external_url.

				
					nano /etc/gitlab/gitlab.rb
				
			

Change the following line:

				
					external_url 'http://gitlab.example.com'
				
			

Save and close the file, then reconfigure the GitLab by running the following command:

				
					gitlab-ctl reconfigure
				
			

This will configure the GitLab and set the root password to access the GitLab web interface:

				
					Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!

				
			

You can retrieve the root password using the following command:

				
					cat /etc/gitlab/initial_root_password
				
			

You should see your root password in the following output:

				
					# 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 first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: w+ZAVoKMB81VmCNJYuP6gyxqz8ZeTxdbEDY8OgRPmiw=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

				
			

You can also check the status of the GitLab using the following command:

				
					gitlab-ctl status
				
			

You will get the following output:

				
					run: gitaly: (pid 21669) 67s; run: log: (pid 19999) 317s
run: gitlab-exporter: (pid 21602) 72s; run: log: (pid 20478) 201s
run: gitlab-workhorse: (pid 21580) 73s; run: log: (pid 20373) 220s
run: grafana: (pid 21856) 56s; run: log: (pid 21360) 100s
run: logrotate: (pid 19897) 330s; run: log: (pid 19909) 329s
run: nginx: (pid 20400) 216s; run: log: (pid 20409) 214s
run: node-exporter: (pid 21588) 73s; run: log: (pid 20457) 207s
run: postgres-exporter: (pid 21850) 57s; run: log: (pid 20926) 153s
run: postgresql: (pid 20055) 311s; run: log: (pid 20146) 308s
run: prometheus: (pid 21617) 71s; run: log: (pid 20520) 190s
run: puma: (pid 20319) 235s; run: log: (pid 20328) 232s
run: redis: (pid 19937) 324s; run: log: (pid 19951) 321s
run: redis-exporter: (pid 21611) 71s; run: log: (pid 20501) 194s
run: sidekiq: (pid 20337) 229s; run: log: (pid 20349) 225s

				
			

Access GitLab Web Interface

At this point, GitLab is installed and configured. Now, you can access the GitLab web interface using the URL http://gitlab.example.com. You will be redirected to the GitLab login page:

Provide your root username, password and click on the Sign in button. You should see the GitLab web interface on the following page:

Click on the New project button to create your first project. You should see the following page:

Click on the Create blank project button. You should see the following page:

Provide your project name, description and click on the Create project button. You should see your project on the following page:

How to Configure GitLab Backup?

It is recommended to create a backup of your GitLab instance. You can create it by running the following command:

				
					gitlab-rake gitlab:backup:create
				
			

You will get the following output:

				
					2022-01-19 07:21:48 +0000 -- done
2022-01-19 07:21:48 +0000 -- Dumping uploads ... 
2022-01-19 07:21:48 +0000 -- done
2022-01-19 07:21:48 +0000 -- Dumping builds ... 
2022-01-19 07:21:48 +0000 -- done
2022-01-19 07:21:48 +0000 -- Dumping artifacts ... 
2022-01-19 07:21:48 +0000 -- done
2022-01-19 07:21:48 +0000 -- Dumping pages ... 
2022-01-19 07:21:48 +0000 -- done
2022-01-19 07:21:48 +0000 -- Dumping lfs objects ... 
2022-01-19 07:21:48 +0000 -- done
2022-01-19 07:21:48 +0000 -- Dumping container registry images ... 
2022-01-19 07:21:48 +0000 -- [DISABLED]
Creating backup archive: 1642576908_2022_01_19_14.6.3_gitlab_backup.tar ... done
Uploading backup archive to remote storage  ... skipped
Deleting tmp directories ... done

				
			

By default, the backup is stored at /var/opt/gitlab/backups. You can change the backup path by editing the settings in the GitLab configuration file at /etc/gitlab/gitlab.rb.

You can verify the generated backup using the following command:

				
					ls /var/opt/gitlab/backups
				
			

You will get the following output:

				
					1642576908_2022_01_19_14.6.3_gitlab_backup.tar
				
			

Reset GitLab Root Password

If you forget the GitLab administrator password then you can reset it easily using the following command:

				
					gitlab-rake "gitlab:password:reset"
				
			

You will be asked to set your new password as shown below:

				
					Enter username: root
Enter password: 
Confirm password: 
Password successfully updated for user with username root.
				
			

Install Gitlab Self Hosted Server on Ubuntu 20.04 Conclusion

In the above guide, we explained how to install GitLab self hosted server on Ubuntu 20.04. You can now implement GitLab in your development environment to speed up the software development process.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x