Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up a Private GitLab Instance on CentOS 7

Tech 1

This guide outlines the steps to deploy a private GitLab instance on a CentOS 7 system.

Prerequisites

Install required dependencies:

sudo yum install curl policycoreutils openssh-server openssh-client
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

Installation

Method 1: Install via YUM Repository

sudo yum install -y gitlab-ce

Method 2: Install Specific Version

Download the desired version from the mirror site:

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

Install the downloaded RPM package:

rpm -i gitlab-ce-11.6.3-ce.0.el7.x86_64.rpm

If you encounter an error related to policycoreutils-python, install it:

sudo yum -y install policycoreutils-python

Configuration

Edit the GitLab configuration file:

vim /etc/gitlab/gitlab.rb

Locate the external_url setting and update it with your domain or IP address and port.

Apply the configuration changes:

sudo gitlab-ctl reconfigure

This process may take several minutes. A successful configuration is indicated by completion messages.

Starting GitLab

Start the GitLab services:

sudo gitlab-ctl start

Common GitLab Commands

# Remove all GitLab-related files
find / -name gitlab | xargs rm -rf

# Start all GitLab components
sudo gitlab-ctl start

# Stop all GitLab components
sudo gitlab-ctl stop

# Restart all GitLab components
sudo gitlab-ctl restart

# Check service status
sudo gitlab-ctl status

# View logs
sudo gitlab-ctl tail

# View logs for a specific service
sudo gitlab-ctl tail <service_name>

After starting GitLab, access it via you're configured IP address and port.

Accessing the Administrator Account

Default Root Password

View the initial root password:

vi /etc/gitlab/initial_root_password

Creating an Administrator Account

If the initial password file is unavailable, create an administrator account via the Rails console:

sudo gitlab-rails console

Execute the following commands in the console:

admin_user = User.new(email: 'admin@example.com', username: 'admin_user', name: 'Administrator', password: 'secure_password')

admin_user.skip_confirmation!

admin_user.save!

# Assign administrator role
admin_user.add_role(:admin)

# Exit the console
quit

Migration Considerations

For migration purposes, note the following:

  1. Ensure GitLab versions are consistent.
  2. Key data directories:
    • Project repository path: /var/opt/gitlab/git-data/repositories
    • PostgreSQL data path: /var/opt/gitlab/postgresql/data

Set appropriate permissions for these directories:

sudo chown -R git:root /var/opt/gitlab/git-data/repositories
sudo chmod -R 0700 /var/opt/gitlab/git-data/repositories
sudo chown -R gitlab-psql:gitlab-psql /var/opt/gitlab/postgresql/data
sudo chmod -R 0700 /var/opt/gitlab/postgresql/data
Tags: GitLabcentos

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.