Operations 4 min read

GitLab Installation and Basic Configuration Guide on CentOS

This guide walks through installing GitLab on a CentOS server, configuring its external URL, setting up admin credentials, performing basic GitLab operations such as disabling auto‑registration, creating projects, configuring SSH keys, testing repository cloning, and configuring webhooks and backup management.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
GitLab Installation and Basic Configuration Guide on CentOS

This article provides a step‑by‑step tutorial for installing and configuring GitLab on a CentOS host.

1. Install required dependencies

yum install curl policycoreutils openssh-server openssh-clients policycoreutils-python

2. Download and install the GitLab package

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.10.9-ce.0.el7.x86_64.rpm
rpm -ivh gitlab-ce-14.7.7-ce.0.el7.x86_64.rpm

Replace the external URL in /etc/gitlab/gitlab.rb :

sed -i '/^external_url/ s#http.*com#http://192.168.40.24#g' /etc/gitlab/gitlab.rb

Reconfigure and start GitLab:

gitlab-ctl reconfigure
gitlab-ctl start

3. Set the admin password via Rails console

gitlab-rails console -e production
user = User.where(id:1).first
user.password = 'admin1234'
user.password_confirmation = 'admin1234'
user.save

4. Basic GitLab operations

Disable automatic user registration in the admin settings.

Create a new project through the UI (screenshots omitted).

Configure an SSH key for the GitLab user.

Test cloning the repository:

git config --global user.name "hahashen"
git config --global user.email "[email protected]"
cd tian-sir/
touch java.txt
git add java.txt
git commit -m "add java"
git push -u origin master

5. Configure GitLab webhook

(The article includes screenshots showing where to add the webhook URL in the project settings.)

6. Backup management

Add the following to /etc/gitlab/gitlab.rb to define backup location and retention:

gitlab_rails['backup_path'] = '/data/backup/gitlab'
gitlab_rails['backup_keep_time'] = 604800

Create the backup directory and set proper permissions:

mkdir /data/backup/gitlab
chown -R git.git /data/backup/gitlab

Run the backup command:

/usr/bin/gitlab-rake gitlab:backup:create

The article concludes with screenshots of the backup process.

configurationGitLabLinuxInstallationbackupwebhook
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.