How to Install, Configure, and Operate GitLab CE on CentOS
This guide walks through installing GitLab CE, configuring its URL and email settings, managing services, applying Chinese localization, creating projects via HTTP and SSH, adding remote repositories, and handling users and groups, providing complete hands‑on instructions for DevOps teams.
GitLab introduction
Private code repository; alternatives include Gogs.
Fine‑grained permission configuration.
Control user/group permissions to prevent unauthorized pushes to master.
GitLab architecture
Deploy GitLab CE
# Use Tsinghua mirror to install directly
yum install -y https://mirrors.tuna.tsinghua.edu.cn/gitlabce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
# Or install a local RPM
yum localinstall -y gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
# Configure external URL in /etc/gitlab/gitlab.rb
external_url 'http://gitlab.wc.com'
# Email configuration example
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
# Disable Prometheus and related exporters if not needed
prometheus['enable'] = false
prometheus_monitor['enable'] = false
node_exporter['enable'] = false
redis_exporter['enable'] = false
postgres_exporter['enable'] = false
gitlab_monitor['enable'] = false
grafana['enable'] = false
alertmanager['enable'] = false
# Reload configuration
gitlab-ctl reconfigure
# Verify reconfiguration
Chef Client finished, 299/430 resources updated in 02 minutes 28 seconds
gitlab Reconfigured!GitLab operations
# Check service status
gitlab-ctl status
# Stop all services
gitlab-ctl stop
# Start all services
gitlab-ctl start
# Restart all services
gitlab-ctl restart
# Stop a specific service (e.g., nginx)
gitlab-ctl stop nginx
# Start a specific service
gitlab-ctl start nginx
# View logs for all components
gitlab-ctl tail
# View logs for a specific component
gitlab-ctl tail nginx
# Open Rails console
gitlab-rails console
# Test email sending
Notify.test_email('[email protected]', 'sbsbsb', 'hei/hei/hei').deliver_now
# Reset root password via console
user = User.where(id: 1).first
user.password = '123456789'
user.password_confirmation = '123456789'
user.saveGitLab Chinese localization
# Download Chinese language pack
wget https://gitlab.com/xhang/gitlab/-/archive/10-2-stable-zh/gitlab10-2-stable-zh.tar.gz
# Extract the package
tar xf gitlab-10-2-stable-zh.tar.gz
# Stop all services
gitlab-ctl stop
# Overwrite existing files with the localized ones
\cp -a gitlab-10-2-stable-zh/* /opt/gitlab/embedded/service/gitlabrails/
# Reload configuration and start services
gitlab-ctl reconfigure
gitlab-ctl startCreate a project (HTTP)
# Global Git configuration
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
# Use an 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
# Use an existing Git repository
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 --tagsCreate a project (SSH)
# Global Git configuration
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 via SSH
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 repository via SSH
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 --tagsAdd a remote repository
# Add remote
git remote add zls [email protected]:root/linux2.git
# Add hosts entry for DNS resolution
vim /etc/hosts
# Add line: 10.0.0.91 gitlab.zls.com
# Generate SSH key pair
ssh-keygen
# View public key
cat ~/.ssh/id_rsa.pub
# Add the public key in the GitLab web UIGitLab user and group management (screenshots omitted for brevity)
Clone a GitLab repository
# Clone repository via SSH
git clone [email protected]:ops/new_linux2.git
# Pull latest changes
git pull
# Fetch all branches
git fetch -vpSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
