1. Home
  2. Linux
  3. How to install gitlab on ubuntu server

How to install GitLab on Ubuntu Server

Are you looking to get GitLab working on your Ubuntu server? GitLab is a powerful self-hostable alternative to services like GitHub. With it, you can easily manage your team and collaborate on coding projects, track bugs, and deploy software. In this guide, we’ll go over the steps it takes to install and deploy your GitLab instance on Ubuntu Server.

xr:d:DAFds8YL9ik:2,j:43601822907,t:23032003

How to install GitLab on your Ubuntu Server

Setting up the GitLab service on your Ubuntu server starts by installing a few packages. These packages are dependencies and are required to run GitLab on Ubuntu. To install these dependencies, enter the following command.

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

With these packages installed on your Ubuntu server, you must download the following GitLab installation script to your Ubuntu system. This script will configure GitLab repos on Ubuntu, and ensure everything can run on your Ubuntu system.

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

After running the script above, you can run the following apt install command to install the “gitlab-ce” package. This package includes everything to host your GitLab instance on an Ubuntu server.

sudo apt install gitlab-ce

The installation of the “gitlab-ce” package will take a lot of time to complete. You may be concerned that your server has frozen or slowed down. Be patient, GitLab is just being set up.

When the GitLab installation is complete on Ubuntu, you’ll see the following message appear in the terminal window.

 

Now that GitLab is installed, you must configure it. Find out your Ubuntu server’s LAN IP address to continue to the next section of the guide.

How to configure GitLab on your Ubuntu Server

You must add an external URL to your GitLab configuration for it to be accessible on the Ubuntu server. To do this, start by opening up a terminal on the Ubuntu server. Once it is open, use the following command to open up the config file.

sudo nano /etc/gitlab/gitlab.rb

Inside the configuration file, scroll down and locate the line:

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

Change the example URL to your hostname, domain, or IP address. When you’ve finished editing the configuration file, press Ctrl + O on the keyboard to save your edits. You can then press Ctrl + X on the keyboard to exit the Nano text editor.

After exiting the Nano text editor, you’ll need to restart the GitLab service so that the changes you’ve made will be applied. Restarting the GitLab service is done with the gitlab-ctl command.

sudo gitlab-ctl reconfigure

How to create your first repo on GitLab

Now that you’ve got a GitLab server set up, it’s time to create your first repo. However, you must first create your user. Access your GitLab URL, and click register to register a new account.

After registering a new account, you must log into the root account to approve it. GitLab automatically generates a secure root password after installation. You can access the root password by doing the following command.

sudo cat /etc/gitlab/initial_root_password | grep "Password"

Copy the securely generated password and log in with the username “root”. Once logged in, click on the hamburger menu (to the left of the GitLab search box) and select “Admin area.”

Inside the “Admin” area, select “View latest users,” and approve the account you created previously. Then, log out of the “root” account and into your registered account.

Once you’ve logged into GitLab, you’re ready to create your first repo. Find the “Create a project” button, and select it with the mouse. Select “Create from template.” Then, browse through the templates for the one that suits your project the best.

After selecting your template, you’ll see the “create from template” area. On this page, you can fill out your project name, project URL, project slub, description, etc. When you’ve finished setting up your new project, click the “Create project button.”

When you select the “Create project” button, your new repo will appear.

How to interact with your new GitLab repo

There are several ways you can interact and push/pull code from your new GitLab repo. On Linux, you can turn to several GUI apps, like GitKraken, Gitg, Git Cola, SmartGit, etc. Alternatively, you can use the official Git command-line tool.

This guide’s purpose is to deploy a GitLab instance on an Ubuntu Server. However, we will not be providing a crash course on how to use Git. For information on how to use the Git tool properly, install one of the apps mentioned and consult their manuals. Or, check Git.org.

Leave a Reply

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.