GitLab is an open-source DevOps platform which provides Git repositories management, continuous integration, issue tracking, and other features. Self-managed GitLab can be installed on the own server.
This tutorial explains how to install GitLab Community Edition (CE) on Ubuntu 20.04.
Prepare environment
Run the following command to update the package lists:
sudo apt update
Make sure you have installed OpenSSH server:
sudo apt install -y openssh-server
Install GitLab CE
Add the GitLab CE package repository:
wget -qO - https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Install the GitLab CE:
sudo apt install -y gitlab-ce
When installation is completed, we can check GitLab CE version:
grep gitlab /opt/gitlab/version-manifest.txt
Now we need to set the URL which will be used to access the GitLab instance. It can be done in configuration file:
sudo nano /etc/gitlab/gitlab.rb
Find external_url
parameter and set IP address or hostname of your machine. Default port is 80, but you can explicitly set if needed.
external_url 'http://192.168.0.188:9000'
To make changes to take effect, reconfigure the GitLab:
sudo gitlab-ctl reconfigure
When it finished, we can check the status of GitLab services:
sudo gitlab-ctl status
We can also stop, start and restart the GitLab services:
sudo gitlab-ctl stop
sudo gitlab-ctl start
sudo gitlab-ctl restart
Testing GitLab CE
By default, a random password is generated during installation. Password can be found in the following file:
sudo cat /etc/gitlab/initial_root_password
Now open the browser and enter IP address or hostname to access the GitLab web interface. Use a username root
and password from a file to login.
Password can be changed in user settings page:
<GITLAB_URL>/-/profile/password/edit
Uninstall GitLab CE
If you want to completely remove GitLab CE, execute the following command:
sudo apt purge --autoremove -y gitlab-ce
When it finished, remove systemd service:
sudo service gitlab-runsvdir stop
sudo systemctl disable gitlab-runsvdir
sudo rm -rf /usr/lib/systemd/system/gitlab-runsvdir.service
sudo systemctl daemon-reload
sudo systemctl reset-failed
Remove GPG key and repository:
sudo apt-key del 51312F3F
sudo rm -rf /etc/apt/sources.list.d/gitlab_gitlab-ce.list
Remove GitLab users:
sudo deluser gitlab-www
sudo deluser gitlab-redis
sudo deluser gitlab-psql
sudo deluser gitlab-prometheus
sudo deluser git
You can also remove GitLab configuration, logs, data, and other related directories:
sudo rm -rf /etc/gitlab
sudo rm -rf /var/log/gitlab
sudo rm -rf /var/opt/gitlab
sudo rm -rf /run/gitlab
sudo rm -rf /opt/gitlab
sudo rm -rf /usr/bin/gitlab-redis-cli
Leave a Comment
Cancel reply