Operations 9 min read

Step-by-Step Guide to Installing, Configuring, and Managing GitLab CE on CentOS

This article walks you through GitLab's core features, architecture diagram, installation via Tsinghua mirrors, detailed configuration, service management commands, Chinese localization steps, project creation over HTTP and SSH, and remote repository handling, providing a comprehensive DevOps reference.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Step-by-Step Guide to Installing, Configuring, and Managing GitLab CE on CentOS

GitLab introduction

Private code repository, alternatives like Gogs

Fine-grained permission configuration

Control user/group permissions to prevent direct master pushes

GitLab architecture

Deploy GitLab CE

# Use Tsinghua mirror to install
[root@gitlab ~]# yum install -y https://mirrors.tuna.tsinghua.edu.cn/gitlabce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

# Local install
[root@gitlab ~]# yum localinstall -y gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm

# Configuration steps (edit /etc/gitlab/gitlab.rb)
# Set external_url, email settings, and disable unwanted Prometheus exporters
# Example:
external_url 'http://gitlab.wc.com'
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_display_name'] = 'wc gitlab notice'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "dizyzzjjujhxdefe"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
# Reconfigure GitLab
[root@gitlab ~]# gitlab-ctl reconfigure

GitLab service operations

# View service status
[root@gitlab git]# gitlab-ctl status

# Stop all services
[root@gitlab git]# gitlab-ctl stop

# Start all services
[root@gitlab git]# gitlab-ctl start

# Restart all services
[root@gitlab git]# gitlab-ctl restart

# Stop a specific service (e.g., nginx)
[root@gitlab git]# gitlab-ctl stop nginx

# Start a specific service
[root@gitlab git]# gitlab-ctl start nginx

# Tail all component logs
[root@gitlab git]# gitlab-ctl tail

# Tail logs of a specific component (e.g., nginx)
[root@gitlab git]# gitlab-ctl tail nginx

# Open Rails console
[root@gitlab git]# gitlab-rails console

# Test email delivery
irb(main):012:0> Notify.test_email('[email protected]','sbsbsb','hei/hei/hei').deliver_now

# Reset root password via Rails console
irb(main):011:0> user = User.where(id: 1).first
irb(main):012:0> user.password = '123456789'
irb(main):012:0> user.password_confirmation = '123456789'
irb(main):012:0> user.save

GitLab Chinese localization

# 1. Download localization package
[root@gitlab ~]# wget https://gitlab.com/xhang/gitlab/-/archive/10-2-stable-zh/gitlab10-2-stable-zh.tar.gz

# 2. Extract package
[root@gitlab ~]# tar xf gitlab-10-2-stable-zh.tar.gz

# 3. Stop all services
[root@gitlab ~]# gitlab-ctl stop

# 4. Overwrite files
[root@gitlab ~]# cp -a gitlab-10-2-stable-zh/* /opt/gitlab/embedded/service/gitlabrails/

# 5. Reconfigure
[root@gitlab ~]# gitlab-ctl reconfigure

# 6. Start services
[root@gitlab ~]# gitlab-ctl start

Create projects (HTTP)

# Global Git config
git config --global user.name "Administrator"
git config --global user.email "[email protected]"

# Clone a new repository
git clone http://gitlab.zls.com/root/linux2.git
cd linux2
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

# Existing folder
cd existing_folder
git init
git remote add origin http://gitlab.zls.com/root/linux2.git
git add .
git commit -m "Initial commit"
git push -u origin master

# Existing Git repo
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.zls.com/root/linux2.git
git push -u origin --all
git push -u origin --tags

Create projects (SSH)

# Global Git config
git config --global user.name "Administrator"
git config --global user.email "[email protected]"

# Clone via SSH
git clone [email protected]:root/linux2.git
cd linux2
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

# Existing folder
cd existing_folder
git init
git remote add origin [email protected]:root/linux2.git
git add .
git commit -m "Initial commit"
git push -u origin master

# Existing Git repo
cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:root/linux2.git
git push -u origin --all
git push -u origin --tags

Add remote repository

# Add remote
[root@gitlab web]# git remote add zls [email protected]:root/linux2.git

# Add hosts entry
[root@gitlab web]# vim /etc/hosts
10.0.0.91 gitlab.zls.com

# Generate SSH key
[root@gitlab git]# ssh-keygen

# View public key
[root@gitlab git]# cat ~/.ssh/id_rsa.pub

# Add SSH key in GitLab web UI

Clone repository

# Clone via SSH
[root@gitlab opt]# git clone [email protected]:ops/new_linux2.git

# Pull latest changes
[root@gitlab new_linux2]# git pull

# Fetch all branches
[root@gitlab new_linux2]# git fetch -vp

GitLab user and group management (screenshots omitted for brevity)

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdDevOpsGitLabLinuxVersionControlServerSetup
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

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.