Installing GitLab on Linux Cloud Servers

2020-02-25 By Aaron 4924 Views linux gitlab development
2 reviews

GitLab is a complete DevOps platform to manage git repositories on a centralized server. It offers free private repositories for open source projects and also you can upload your repositories and make them public or private.


This guide outlines the general steps to install GitLab in different Linux distributions.


CentOS 7/8


  1. Run update before proceeding with the installation.

    # yum -y update
    

    gitlab1

  2. Install the following dependencies.

    # yum -y install curl vim policycoreutils python3-policycoreutils
    

    gitlab2

  3. Create a new repository file for GitLab.

    # vi /etc/yum.repos.d/gitlab-ce.repo
    

    gitlab3

    [gitlab-ce]
    name=gitlab-ce
    baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/$basearch
    repo_gpgcheck=1
    gpgcheck=1
    enabled=1
    gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
           https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
    metadata_expire=300
    

    gitlab4

  4. Save the file and execute the following command.

    # yum makecache
    

    gitlab5

  5. Install GitLab by running the command.

    # yum install -y gitlab-ce --nobest
    

    gitlab6


Debian / Ubuntu


  1. Run update before proceeding with the installation.

    # apt-get update
    

    gitlab7

  2. Install the following dependencies.

    # apt install ca-certificates curl openssh-server
    

    gitlab8

  3. Install the GitLab using the installation script.

    Create a folder GitLab and move into that directory:

    # mkdir GitLab
    
    # cd GitLab
    

    gitlab9

  4. Execute the below command to download the script.

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

    gitlab10

  5. Give execute permission to the downloaded script.

    # chmod +x script.deb.sh
    

    gitlab11

  6. Execute the script file.

    # bash script.deb.sh
    

    gitlab12

  7. Then execute the following command.

    # apt install gitlab-ce
    

    gitlab13


Configuring GitLab

Once the installation has been completed, GitLab can be configured according to one’s own working environment. The main configuration file for GitLab can be found under /etc/gitlab/gitlab.rb.


One of the main configurations that need to be done is to set the URL on which GitLab will be reachable.

  1. Open the GitLab configuration file using any editor.

    # vi /etc/gitlab/gitlab.rb
    
  2. Scroll down to the value external_url and set the URL on which GitLab can be accessed. In the below example, the server IP 123.123.123.123 has been used.

    gitlab14

  3. Make any further configuration changes as per requirement and once done, save and quit the file. Execute the below command to run the GitLab reconfiguration script.

    # gitlab-ctl reconfigure
    
  4. Once the GitLab has been successfully reconfigured, an output similar to below will be displayed.

    gitlab15


Testing GitLab

Once GitLab has been reconfigured, it can be accessed through any browsers using the URL value that has been specified in the configuration file.


  1. Upon browsing for the first time, a password reset screen will be shown from which a new password for the new admin account can be set up. Clicking on Change your password after typing in the password, the page will be redirected back to the GitLab login screen.

    gitlab16

  2. Login with root user and the newly set password to access the GitLab admin dashboard, from where projects, as required, can be created.

    gitlab17

What do you think about this article?

Rate this article
LayerStack Promotion
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.