CICD

How to install and set up Gitlab CE Server on Centos 8

Pinterest LinkedIn Tumblr

GitLab allows you to host an on-premise Git repository that can be accessed from either your local LAN or (if you have an available public IP address) from outside your company. GitLab is an open-source repository manager based on Rails developed by GitLab Inc. It is a web-based git repository manager that allows your team to collaborate on coding, testing, and deploying applications. GitLab provides several features, including wikis, issue tracking, code reviews, and activity feeds.

In this guide, we will install the GitLab CE on the CentOS 8 server. We will install the GitLab CE using the ‘omnibus’ package provided by GitLab.

Prerequisites

  • Updated Centos 8 server
  • Access to the internet
  • Ensure that your server is at lease 4GB of RAM with more than 20GB of disk space and 2 CPUs

Table of Content

  • Ensure that Centos 8 server packages are up to date
  • Installing GitLab CE

Ensure that Centos 8 server packages are up to date

Before proceeding let us update our Centos 8 server using this command:

sudo dnf -y update

Install common packages that will be essential

sudo dnf install -y vim

Install and configure the necessary dependencies

Before proceeding let’s ensure that the pakages needed are installed. Use this command:

sudo dnf install -y curl policycoreutils openssh-server perl

Next, ensure that the ssh server is started and enabled to start on boot:

sudo systemctl start sshd
sudo systemctl enable sshd

If you have firewall enabled, open up http and https traffic using this command:

sudo firewall-cmd --permanent --add-service={ssh,http,https} --permanent 
sudo firewall-cmd --reload

Our Gitlab CE server will be sending emails. Let us install postfix for this purpose:

sudo dnf install -y postfix

Then let’s enable and start the service:

sudo systemctl enable postfix
sudo systemctl start postfix

Add the GitLab package repository and install the package

Add the GitLab package repository.

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

Next, install the GitLab package. We will use a custom domain to access our Gitlab instance. Ensure that you have mapped the DNS records for your domai to point to the server where you are installing Gitlab. Installation will automatically configure and start GitLab at that URL.

sudo EXTERNAL_URL="http://gitlab.citizix.com" dnf install -y gitlab-ce

Configuring Gitlab CE

Now that gitlab is successfully installed, let’s configure it. The main configuration file can be found in the file/etc/gitlab/gitlab.rb. Open the file (vim /etc/gitlab/gitlab.rb) and confirm that the external url is set as defined during installation:

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

Save & and run the reconfiguration script

sudo gitlab-ctl reconfigure

Wait for the configuration script to finish. You should see something similar to this:

Recipe: gitlab::database_reindexing_disable
  * crond_job[database-reindexing] action delete
    * file[/var/opt/gitlab/crond/database-reindexing] action delete (up to date)
     (up to date)

Running handlers:
Running handlers complete
Chef Infra Client finished, 4/766 resources updated in 01 minutes 22 seconds
gitlab Reconfigured!

Accessing Gitlab CE

Once the configuration is complete, Gitlab CE is available in the URL provided (In my case http://gitlab.citizix.com. Ensure that the DNS entry for the URL is pointing to the server then access that url in the browser. You should be redirected to the login page as shown below:

Gitlab CE Sign in Page

Unless you provided a custom password during installation, a password will be randomly generated and stored for 24 hours in /etc/gitlab/initial_root_password. Use this password with username root to login.

sudo cat /etc/gitlab/initial_root_password

Once logged in you can use the gitlab server to create and manange projects and repositories.

Conclusion

Congratulations, you now have your local GitLab up and running.  You can now use your Gitlab CE Server to manage repositories and projects.

Have fun!

I am a Devops Engineer, but I would describe myself as a Tech Enthusiast who is a fan of Open Source, Linux, Automations, Cloud and Virtualization. I love learning and exploring new things so I blog in my free time about Devops related stuff, Linux, Automations and Open Source software. I can also code in Python and Golang.

Write A Comment