How to Uninstall and Reinstall GitLab CE on Linux: A Complete Step‑by‑Step Guide
This guide walks you through safely stopping, removing, and reinstalling GitLab CE on a Linux server, covering dependency installation, configuration tweaks, port management, firewall settings, and essential GitLab commands for daily administration.
01 Uninstall GitLab
Stop the GitLab services and verify they are down:
# Stop GitLab
gitlab-ctl stop
# Check status
gitlab-ctl statusIf all services report down, the stop was successful.
Uninstall the GitLab CE package: rpm -e gitlab-ce Remove any remaining GitLab processes: ps -ef | grep gitlab Kill lingering processes (replace 202859 with the actual PID): kill -9 202859 Finally, delete all GitLab files from the system:
find / -name gitlab | xargs rm -rf02 Install Dependencies
# Install required packages
yum install -y curl policycoreutils openssh-server
# Enable and start SSH
systemctl enable sshd
systemctl start sshd
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
systemctl reload firewalld
# Install Postfix for email notifications
yum install -y postfix
systemctl enable postfix
systemctl start postfix03 Install GitLab‑CE
Download the GitLab CE package from the official site or a Chinese mirror (e.g., Tsinghua University). Place the RPM in /usr/local and install:
# Change to the directory containing the RPM
cd /usr/local
# Install the package (example version 13.7.2)
rpm -ivh gitlab-ce-13.7.2-ce.0.el8.x86_64.rpmIf the firewall blocks access, stop and disable it temporarily:
systemctl stop firewalld
systemctl disable firewalldEnsure the server has at least 4 GB of RAM: free -m Configure required ports (default values shown):
# puma['port'] = 8080
# postgresql['port'] = 5432
# redis['port'] = 6379
# sentinel['port'] = 26379
# nginx['listen_port'] = nil
# nginx['listen_https'] = nilEdit /etc/gitlab/gitlab.rb to set the external URL and custom ports, for example:
# Set HTTP access address (no port defaults to 80)
external_url 'http://192.168.138.8:9080'
# Change Nginx listen port
nginx['listen_port'] = 9080
# Change Puma port
puma['port'] = 9081
# Set time zone
gitlab_rails['time_zone'] = 'Asia/Shanghai'
# Backend authentication address
gitlab_workhorse['auth_backend'] = "http://localhost:9081"Note: Starting with GitLab 13.0, Puma is the default web server and Unicorn is disabled.
Apply the configuration and restart services:
gitlab-ctl reconfigure
gitlab-ctl restart04 Login to GitLab
Open the browser at http://192.168.138.8:9080, set the root password (minimum 8 characters, e.g., root1234), and log in.
05 Daily GitLab Usage
File Paths
Query installed file locations with: rpm -ql gitlab-ce Key directories include:
# Main configuration file
/etc/gitlab/gitlab.rb
# Default installation path
/opt/gitlab
# Repository storage
/var/opt/gitlab/git-data/repositories
# Backups
/var/opt/gitlab/backups
# Nginx config
/var/opt/gitlab/nginx/conf/gitlab-http.conf
# PostgreSQL data
/var/opt/gitlab/postgresql/data
# Redis config
/var/opt/gitlab/redis
# Logs
/var/log/gitlabGitLab Service Components
# GitLab service composition
nginx: static web server
gitlab-shell: handles Git commands and authorized_keys
gitlab-workhorse: lightweight reverse proxy
logrotate: log file management
postgresql: database
redis: cache database
sidekiq: background job processing
unicorn: HTTP server (pre‑13.0)
puma: HTTP server (13.0 and later)Common Commands
# Reconfigure GitLab
gitlab-ctl reconfigure
# Start services
gitlab-ctl start
# Stop services
gitlab-ctl stop
# Restart services
gitlab-ctl restart
# View logs in real time
gitlab-ctl tail
# View module‑specific logs
gitlab-ctl tail redis/postgresql/gitlab-workhorse/logrotate/nginx/sidekiq/unicorn/puma
# Help
gitlab-ctl --help
# Run health check
gitlab-rake gitlab:check SANITIZE=true --traceSigned-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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
