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.
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-python2. 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.rpmReplace the external URL in /etc/gitlab/gitlab.rb :
sed -i '/^external_url/ s#http.*com#http://192.168.40.24#g' /etc/gitlab/gitlab.rbReconfigure and start GitLab:
gitlab-ctl reconfigure gitlab-ctl start3. 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.save4. 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 master5. 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'] = 604800Create the backup directory and set proper permissions:
mkdir /data/backup/gitlab chown -R git.git /data/backup/gitlabRun the backup command:
/usr/bin/gitlab-rake gitlab:backup:createThe article concludes with screenshots of the backup process.
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.
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.