How to Install and Configure GitLab CE on CentOS 8/7
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.
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:
- 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.com2. Update the system packages to the latest version
[root@gitlab ~]# yum update3. 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 perl4. Enable OpenSSH server daemon if not enabled
[root@gitlab ~]# systemctl status sshd
[root@gitlab ~]# systemctl start sshd
[root@gitlab ~]# systemctl enable sshd5. 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 --reload6. 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 postfix7. 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-ce9. 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 status12. 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_in14. 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.
Now, we are connected with our GitLab server. We have successfully install GitLab server on our CentOS 8 machine.
