Sitemap

How to Install and Configure GitLab CE on CentOS 8/7

3 min readAug 27, 2023

GitLab CE (Community Edition) is an open-source application used to host Git repositories with additional features like issue tracking. GitLab CE is using your own infrastructure to host repositories which provide flexibility in deploying as an internal repository.

Press enter or click to view image in full size

Prerequisites

→ at least 4GB of RAM memory
→ 2 CPU cores
→ at least 2GB of swap space
→ (optional) Domain or subdomain pointing to the server IP address

Visit the official GitLab documentation for the system requirements and installation instructions https://about.gitlab.com/install/#centos-7 and follow these steps:

  1. Configure hostname and IP address
[root@original ~]# hostnamectl set-hostname gitlab.srg.com
[root@original ~]# exec bash
[root@gitlab ~]# vim /etc/hosts
---------------------------------
192.168.13.160 gitlab.srg.com
---------------------------------
[root@gitlab ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
---------------------------------
BOOTPROTO=static
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.13.160
NETMASK=255.255.255.0
GATEWAY=192.168.13.2
DNS1=192.168.13.2
---------------------------------
[root@gitlab ~]# systemctl restart network
[root@gitlab ~]# systemctl restart network
[root@gitlab ~]# hostname
gitlab.srg.com
[root@gitlab ~]# hostname -I
192.168.13.160 192.168.122.1
[root@gitlab ~]# ping google.com

2. Update the system packages to the latest version

[root@gitlab ~]# yum update

3. Install required packages: curl to download the repository installer, policycoreutils for SELinux manager and OpenSSH

[root@gitlab ~]# yum -y install curl policycoreutils-python-utils openssh-server perl

4. Enable OpenSSH server daemon if not enabled

[root@gitlab ~]# systemctl status sshd
[root@gitlab ~]# systemctl start sshd
[root@gitlab ~]# systemctl enable sshd

5. Configure firewall to allow http service

[root@gitlab ~]# firewall-cmd --permanent --add-service=http
[root@gitlab ~]# firewall-cmd --permanent --add-service=https
[root@gitlab ~]# firewall-cmd --reload

6. Install postfix service to send notification emails

[root@gitlab ~]# yum -y install postfix
[root@gitlab ~]# systemctl start postfix
[root@gitlab ~]# systemctl enable postfix
[root@gitlab ~]# systemctl status postfix

7. Add the gitlab official package repository

[root@gitlab ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
...
The repository is setup! You can now install packages.

8. Install gitlab community edition

[root@gitlab ~]# yum -y install gitlab-ce

9. Configure gitlab url for accessing web interface, near the top of the configuration file, you will see a line starting with external_url. Change the value to match your domain/subdomain or IP address

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
---------------------------------

external_url 'http://192.168.13.160'

10. Reconfigure gitlab to apply the recent changes in the configuration file

[root@gitlab ~]# gitlab-ctl reconfigure
---------------------------------

Running handlers:
[2023-08-27T20:35:26+05:45] INFO: Running report handlers
Running handlers complete
[2023-08-27T20:35:26+05:45] INFO: Report handlers complete
Infra Phase complete, 20/815 resources updated in 06 minutes 06 seconds
gitlab Reconfigured!

11. All gitlab services should be started after configuration

[root@gitlab ~]# gitlab-ctl status

12. Change root user password

[root@gitlab ~]# gitlab-rake "gitlab:password:reset"
Enter username: root
Enter password:
Confirm password:
Password successfully updated for user with username root.

13. Open your browser and go to URL http://192.168.13.160 and login with username root and the password you set

http://192.168.13.160/users/sign_in
Press enter or click to view image in full size
GitLab Admin Login

14. After a successful login, it should take you into the admin user account. From, here, you can create an object, create a group, add people or configure your gitlab instance.

Press enter or click to view image in full size
GitLab Admin Control Panel

Now, we are connected with our GitLab server. We have successfully install GitLab server on our CentOS 8 machine.

Testing from Developer’s Machine

Follow the article

--

--

No responses yet