InfoGrab DocsInfoGrab Docs

소스 코드 직접 컴파일 설치

요약

- Offering: GitLab Self-Managed 이 문서는 소스 파일을 사용하여 프로덕션 GitLab 서버를 설정하는 공식 설치 가이드입니다. 이 가이드는 많은 경우를 다루고 필요한 모든 명령어를 포함하기 때문에 내용이 깁니다.

  - 
  Tier: Free, Premium, Ultimate

- Offering: GitLab Self-Managed

이 문서는 소스 파일을 사용하여 프로덕션 GitLab 서버를 설정하는 공식 설치 가이드입니다. Debian/Ubuntu 운영 체제용으로 작성되었으며 해당 환경에서 테스트되었습니다. 하드웨어 및 운영 체제 요구 사항은 requirements.md를 참조하세요. RHEL/CentOS에 설치하려면 Linux 패키지를 사용하세요. 다른 설치 옵션에 대해서는 주요 설치 페이지를 참조하세요.

이 가이드는 많은 경우를 다루고 필요한 모든 명령어를 포함하기 때문에 내용이 깁니다. 아래 단계들은 정상 동작하는 것으로 확인되었습니다. 이 가이드에서 벗어날 때는 주의하세요. GitLab이 환경에 대해 세우는 가정을 위반하지 않도록 하세요. 예를 들어, 디렉터리 위치를 변경하거나 잘못된 사용자로 서비스를 실행하는 경우 권한 문제가 발생하는 경우가 많습니다.

이 가이드에서 버그나 오류를 발견하면, 기여 가이드를 따라 머지 리퀘스트를 제출하세요.

Linux 패키지 설치 고려하기#

소스 코드 직접 컴파일 설치는 작업량이 많고 오류가 발생하기 쉽기 때문에, 빠르고 안정적인 Linux 패키지 설치 (deb/rpm) 방식을 강력히 권장합니다.

Linux 패키지가 더 안정적인 이유 중 하나는, GitLab 프로세스가 충돌할 경우 runit을 사용하여 재시작하기 때문입니다. 사용량이 많은 GitLab 인스턴스에서는 Sidekiq 백그라운드 워커의 메모리 사용량이 시간이 지남에 따라 증가합니다. Linux 패키지는 메모리 사용량이 너무 많아질 경우 Sidekiq이 정상적으로 종료되도록 허용하여 이 문제를 해결합니다. 정상 종료 후 runit은 Sidekiq이 실행되지 않는 것을 감지하고 다시 시작합니다. 소스 코드 직접 컴파일 설치는 프로세스 감시에 runit을 사용하지 않으므로, Sidekiq을 종료할 수 없어 메모리 사용량이 시간이 지남에 따라 증가합니다.

설치할 버전 선택#

설치하려는 GitLab 버전의 브랜치(버전)에서 이 설치 가이드를 확인하세요 (예: 16-0-stable). GitLab의 좌측 상단 모서리(메뉴 바 아래)에 있는 버전 드롭다운 목록에서 브랜치를 선택할 수 있습니다.

가장 높은 번호의 안정 브랜치가 불명확한 경우, GitLab 블로그에서 버전별 설치 가이드 링크를 확인하세요.

소프트웨어 요구 사항#

소프트웨어 최소 버전 비고
Ruby 3.2.x GitLab 16.7부터 17.4까지는 Ruby 3.1이 필요합니다. GitLab 17.5 이상에서는 Ruby 3.2가 필요합니다. 표준 MRI Ruby 구현을 사용해야 합니다. JRuby와 Rubinius도 좋지만, GitLab은 네이티브 확장이 있는 여러 Gem이 필요합니다.
RubyGems 3.5.x 특정 RubyGems 버전이 필요한 것은 아니지만, 알려진 성능 향상 혜택을 받기 위해 업데이트하는 것이 좋습니다.
Go 1.22.x GitLab 17.1 이상에서는 Go 1.22 이상이 필요합니다.
Git 2.47.x GitLab 17.7 이상에서는 Git 2.47.x 이상이 필요합니다. Gitaly에서 제공하는 Git 버전을 사용해야 합니다.
Node.js 20.13.x GitLab 17.0 이상에서는 Node.js 20.13 이상이 필요합니다.
PostgreSQL 16.x GitLab 18.0 이상에서는 PostgreSQL 16 이상이 필요합니다.

GitLab 디렉터리 구조#

설치 단계를 따라가면서 다음 디렉터리들이 생성됩니다:

|-- home
|   |-- git
|       |-- .ssh
|       |-- gitlab
|       |-- gitlab-shell
|       |-- repositories
  • /home/git/.ssh - OpenSSH 설정을 포함합니다. 특히 GitLab Shell이 관리하는 authorized_keys 파일이 있습니다.

  • /home/git/gitlab - GitLab 핵심 소프트웨어입니다.

  • /home/git/gitlab-shell - GitLab의 핵심 애드온 컴포넌트입니다. SSH 클로닝 및 기타 기능을 유지 관리합니다.

  • /home/git/repositories - 네임스페이스별로 구성된 모든 프로젝트의 베어(bare) 리포지터리입니다. 이 디렉터리는 모든 프로젝트의 Git 리포지터리가 푸시/풀되는 곳입니다. 이 영역에는 프로젝트의 중요한 데이터가 포함되어 있습니다. 백업을 유지하세요.

리포지터리의 기본 위치는 GitLab의 config/gitlab.yml과 GitLab Shell의 config.yml에서 설정할 수 있습니다.

지금 이 디렉터리들을 수동으로 생성할 필요가 없으며, 그렇게 하면 나중에 설치 시 오류가 발생할 수 있습니다.

설치 워크플로우#

GitLab 설치는 다음 컴포넌트들을 설정하는 과정으로 구성됩니다:

1. 패키지 및 의존성#

sudo#

sudo는 Debian에 기본적으로 설치되어 있지 않습니다. 시스템을 최신 상태로 업데이트하고 설치하세요.

# run as root!
apt-get update -y
apt-get upgrade -y
apt-get install sudo -y

빌드 의존성#

필요한 패키지를 설치하세요 (Ruby 및 Ruby 젬의 네이티브 확장을 컴파일하는 데 필요합니다):

sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libre2-dev \
  libreadline-dev libncurses5-dev libffi-dev curl openssh-server libxml2-dev libxslt-dev \
  libcurl4-openssl-dev libicu-dev libkrb5-dev logrotate rsync python3-docutils pkg-config cmake \
  runit-systemd
GitLab은 OpenSSL 버전 1.1이 필요합니다. Linux 배포판에 다른 버전의 OpenSSL이 포함된 경우,

1.1을 수동으로 설치해야 할 수도 있습니다.

Git#

다음과 같은 이유로 Gitaly에서 제공하는 Git 버전을 사용해야 합니다:

  • GitLab에서 요구하는 버전을 항상 유지합니다.

  • 정상적인 운영에 필요한 커스텀 패치가 포함될 수 있습니다.

필요한 의존성을 설치합니다:

sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev libpcre2-dev build-essential git-core

Gitaly 리포지터리를 클론하고 Git을 컴파일합니다. <X-Y-stable>을 설치하려는 GitLab 버전에 맞는 안정 브랜치로 교체하세요. 예를 들어, GitLab 16.7을 설치하려면 브랜치 이름 16-7-stable을 사용합니다:

git clone https://gitlab.com/gitlab-org/gitaly.git -b <X-Y-stable> /tmp/gitaly
cd /tmp/gitaly
sudo make git GIT_PREFIX=/usr/local

선택적으로, 시스템 Git 및 의존성을 제거할 수 있습니다:

sudo apt remove -y git-core
sudo apt autoremove

나중에 config/gitlab.yml을 편집할 때, Git 경로를 변경하는 것을 기억하세요:

변경 전:

git:
  bin_path: /usr/bin/git

변경 후:

git:
  bin_path: /usr/local/bin/git

GraphicsMagick#

커스텀 파비콘이 작동하려면 GraphicsMagick이 설치되어 있어야 합니다.

sudo apt-get install -y graphicsmagick

메일 서버#

메일 알림을 수신하려면 메일 서버를 설치해야 합니다. 기본적으로 Debian에는 exim4가 포함되어 있지만 Ubuntu와 달리 이는 문제가 있습니다. 권장 메일 서버는 postfix이며 다음으로 설치할 수 있습니다:

sudo apt-get install -y postfix

그런 다음 Internet Site를 선택하고 Enter를 눌러 호스트명을 확인합니다.

ExifTool#

GitLab Workhorse는 업로드된 이미지에서 EXIF 데이터를 제거하기 위해 exiftool이 필요합니다.

sudo apt-get install -y libimage-exiftool-perl

2. Ruby#

GitLab을 실행하려면 Ruby 인터프리터가 필요합니다. 최소 Ruby 요구 사항은 요구 사항 섹션을 참조하세요.

RVM, rbenv, chruby 같은 Ruby 버전 관리자는 GitLab에서 진단하기 어려운 문제를 유발할 수 있습니다. 대신 공식 소스 코드에서 Ruby를 설치해야 합니다.

3. RubyGems#

경우에 따라 Ruby에 번들된 것보다 최신 버전의 RubyGems가 필요합니다.

특정 버전으로 업데이트하려면:

gem update --system 3.4.12

또는 최신 버전으로:

gem update --system

4. Go#

GitLab에는 Go로 작성된 여러 데몬이 있습니다. GitLab을 설치하려면 Go 컴파일러를 설치해야 합니다. 다음 지침은 64비트 Linux를 사용하는 것으로 가정합니다. 다른 플랫폼의 다운로드는 Go 다운로드 페이지에서 찾을 수 있습니다.

# Remove former Go installation folder
sudo rm -rf /usr/local/go

curl --remote-name --location --progress-bar "https://go.dev/dl/go1.22.5.linux-amd64.tar.gz"
echo '904b924d435eaea086515bc63235b192ea441bd8c9b198c507e85009e6e4c7f0  go1.22.5.linux-amd64.tar.gz' | shasum -a256 -c - && \
  sudo tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,gofmt} /usr/local/bin/
rm go1.22.5.linux-amd64.tar.gz

5. Node#

GitLab은 JavaScript 에셋을 컴파일하기 위해 Node를, JavaScript 의존성을 관리하기 위해 Yarn을 사용합니다. 현재 최소 요구 사항은 다음과 같습니다:

  • node 20.x 릴리스 (v20.13.0 이상). Node.js의 다른 LTS 버전으로도 에셋을 빌드할 수 있을 수 있지만, Node.js 20.x만 보장됩니다.

  • yarn = v1.22.x (Yarn 2는 아직 지원되지 않습니다)

많은 배포판에서 공식 패키지 리포지터리에서 제공하는 버전이 오래되어 있으므로, 다음 명령어를 통해 설치해야 합니다:

# install node v20.x
curl --location "https://deb.nodesource.com/setup_20.x" | sudo bash -
sudo apt-get install -y nodejs

npm install --global yarn

이 단계에서 문제가 발생하면 nodeyarn의 공식 웹사이트를 방문하세요.

6. 시스템 사용자#

GitLab을 위한 git 사용자를 생성합니다:

sudo adduser --disabled-login --gecos 'GitLab' git

7. 데이터베이스#

PostgreSQL만 지원됩니다.

GitLab 18.0 이상에서는 PostgreSQL 16+가 필요합니다.

데이터베이스 패키지를 설치합니다.

Ubuntu 22.04 이상의 경우:

sudo apt install -y postgresql postgresql-client libpq-dev postgresql-contrib

Ubuntu 20.04 이하의 경우, 사용 가능한 PostgreSQL이 최소 버전 요구 사항을 충족하지 않습니다. PostgreSQL 리포지터리를 추가해야 합니다:

sudo curl --fail --silent --show-error --output /etc/apt/keyrings/postgresql.asc \
          --url "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
echo "deb [ signed-by=/etc/apt/keyrings/postgresql.asc ] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" |
     sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get -y install postgresql-16

설치하려는 GitLab 버전에서 지원하는 PostgreSQL 버전인지 확인합니다:

psql --version

PostgreSQL 서비스를 시작하고 서비스가 실행 중인지 확인합니다:

sudo service postgresql start
sudo service postgresql status

GitLab용 데이터베이스 사용자를 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE USER git CREATEDB;"

pg_trgm 확장을 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

btree_gist 확장을 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"

plpgsql 확장을 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS plpgsql;"

GitLab 프로덕션 데이터베이스를 생성하고 해당 데이터베이스에 모든 권한을 부여합니다:

sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;"

새 사용자로 새 데이터베이스에 연결을 시도합니다:

sudo -u git -H psql -d gitlabhq_production

pg_trgm 확장이 활성화되어 있는지 확인합니다:

SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'pg_trgm'
AND installed_version IS NOT NULL;

확장이 활성화된 경우 다음과 같은 출력이 생성됩니다:

enabled
---------
 t
(1 row)

btree_gist 확장이 활성화되어 있는지 확인합니다:

SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'btree_gist'
AND installed_version IS NOT NULL;

확장이 활성화된 경우 다음과 같은 출력이 생성됩니다:

enabled
---------
 t
(1 row)

plpgsql 확장이 활성화되어 있는지 확인합니다:

SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'plpgsql'
AND installed_version IS NOT NULL;

확장이 활성화된 경우 다음과 같은 출력이 생성됩니다:

enabled
---------
 t
(1 row)

데이터베이스 세션을 종료합니다:

gitlabhq_production> \q

8. Redis#

최소 Redis 요구 사항은 요구 사항 페이지를 참조하세요.

다음으로 Redis를 설치합니다:

sudo apt-get install redis-server

설치가 완료되면 Redis를 설정할 수 있습니다:

# Configure redis to use sockets
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig

# Disable Redis listening on TCP by setting 'port' to 0
sudo sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf

# Enable Redis socket for default Debian / Ubuntu path
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf

# Grant permission to the socket to all members of the redis group
echo 'unixsocketperm 770' | sudo tee -a /etc/redis/redis.conf

# Add git to the redis group
sudo usermod -aG redis git

systemd로 Redis 감시하기#

배포판이 systemd init을 사용하고 다음 명령어의 출력이 notify인 경우, 아무 변경도 하지 않아도 됩니다:

systemctl show --value --property=Type redis-server.service

출력이 notify아닌 경우 다음을 실행합니다:

# Configure Redis to not daemonize, but be supervised by systemd instead and disable the pidfile
sudo sed -i \
         -e 's/^daemonize yes$/daemonize no/' \
         -e 's/^supervised no$/supervised systemd/' \
         -e 's/^pidfile/# pidfile/' /etc/redis/redis.conf
sudo chown redis:redis /etc/redis/redis.conf

# Make the same changes to the systemd unit file
sudo mkdir -p /etc/systemd/system/redis-server.service.d
sudo tee /etc/systemd/system/redis-server.service.d/10fix_type.conf <

Redis 비감시 실행#

시스템이 SysV init을 사용하는 경우 다음 명령어를 실행합니다:

# Create the directory which contains the socket
sudo mkdir -p /var/run/redis
sudo chown redis:redis /var/run/redis
sudo chmod 755 /var/run/redis

# Persist the directory which contains the socket, if applicable
if [ -d /etc/tmpfiles.d ]; then
  echo 'd  /var/run/redis  0755  redis  redis  10d  -' | sudo tee -a /etc/tmpfiles.d/redis.conf
fi

# Activate the changes to redis.conf
sudo service redis-server restart

9. GitLab#

# We'll install GitLab into the home directory of the user "git"
cd /home/git

소스 클론#

Community Edition 클론:

# Clone GitLab repository
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-foss.git -b <X-Y-stable> gitlab

Enterprise Edition 클론:

# Clone GitLab repository
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab.git -b <X-Y-stable-ee> gitlab

<X-Y-stable>을 설치하려는 버전에 맞는 안정 브랜치로 교체하세요. 예를 들어, 11.8을 설치하려면 브랜치 이름 11-8-stable을 사용합니다.

최신 "bleeding edge" 버전을 원한다면 `<X-Y-stable>`을 `master`로 변경할 수 있지만, 프로덕션 서버에는 절대 `master`를 설치하지 마세요!

설정하기#

# Go to GitLab installation folder
cd /home/git/gitlab

# Copy the example GitLab config
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

# Update GitLab config file, follow the directions at top of the file
sudo -u git -H editor config/gitlab.yml

# Copy the example secrets file
sudo -u git -H cp config/secrets.yml.example config/secrets.yml
sudo -u git -H chmod 0600 config/secrets.yml

# Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX,go-w log/
sudo chmod -R u+rwX tmp/

# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories
sudo chmod -R u+rwX tmp/pids/
sudo chmod -R u+rwX tmp/sockets/

# Create the public/uploads/ directory
sudo -u git -H mkdir -p public/uploads/

# Make sure only the GitLab user has access to the public/uploads/ directory
# now that files in public/uploads are served by gitlab-workhorse
sudo chmod 0700 public/uploads

# Change the permissions of the directory where CI job logs are stored
sudo chmod -R u+rwX builds/

# Change the permissions of the directory where CI artifacts are stored
sudo chmod -R u+rwX shared/artifacts/

# Change the permissions of the directory where GitLab Pages are stored
sudo chmod -R ug+rwX shared/pages/

# Copy the example Puma config
sudo -u git -H cp config/puma.rb.example config/puma.rb

# Refer to https://github.com/puma/puma#configuration for more information.
# You should scale Puma workers and threads based on the number of CPU
# cores you have available. You can get that number via the `nproc` command.
sudo -u git -H editor config/puma.rb

# Configure Redis connection settings
sudo -u git -H cp config/resque.yml.example config/resque.yml
sudo -u git -H cp config/cable.yml.example config/cable.yml

# Change the Redis socket path if you are not using the default Debian / Ubuntu configuration
sudo -u git -H editor config/resque.yml config/cable.yml

설정에 맞게 gitlab.ymlpuma.rb 모두 편집하세요.

HTTPS를 사용하려면 추가 단계를 위해 HTTPS 사용하기를 참조하세요.

GitLab DB 설정 구성#

[GitLab 15.9](https://gitlab.com/gitlab-org/gitlab/-/issues/387898)부터 `main:` 섹션만 있는 `database.yml`은 더 이상 사용되지 않습니다.

GitLab 17.0 이상에서는 database.ymlmain:ci: 두 섹션이 반드시 있어야 합니다.

sudo -u git cp config/database.yml.postgresql config/database.yml

# Remove host, username, and password lines from config/database.yml.
# Once modified, the `production` settings will be as follows:
#
#   production:
#     main:
#       adapter: postgresql
#       encoding: unicode
#       database: gitlabhq_production
#     ci:
#       adapter: postgresql
#       encoding: unicode
#       database: gitlabhq_production
#       database_tasks: false
#
sudo -u git -H editor config/database.yml

# Remote PostgreSQL only:
# Update username/password in config/database.yml.
# You only need to adapt the production settings (first part).
# If you followed the database guide then please do as follows:
# Change 'secure password' with the value you have given to $password
# You can keep the double quotes around the password
sudo -u git -H editor config/database.yml

# Uncomment the `ci:` sections in config/database.yml.
# Ensure the `database` value in `ci:` matches the database value in `main:`.

# Make config/database.yml readable to git only
sudo -u git -H chmod o-rwx config/database.yml

database.yml에는 main:ci: 두 섹션이 있어야 합니다. ci: 연결은 동일한 데이터베이스에 연결해야 합니다.

Gem 설치#

Bundler 1.5.2부터 `bundle install -jN` (여기서 `N`은 프로세서 코어 수)을 실행하여 병렬 젬 설치를 즐길 수 있으며, 완료 시간에 측정 가능한 차이가 있습니다 (약 60% 빠름). `nproc`으로 코어 수를 확인하세요. 자세한 내용은 이 [게시물](https://thoughtbot.com/blog/parallel-gem-installing-using-bundler)을 참조하세요.

bundle이 있는지 확인하세요 (bundle -v 실행):

  • >= 1.5.2: 1.5.2에서 일부 문제수정되었기 때문입니다.

  • < 2.x.

젬을 설치하세요 (사용자 인증에 Kerberos를 사용하려면 다음 명령어의 --without 옵션에서 kerberos를 제외하세요):

sudo -u git -H bundle config set --local deployment 'true'
sudo -u git -H bundle config set --local without 'development test kerberos'
sudo -u git -H bundle config path /home/git/gitlab/vendor/bundle
sudo -u git -H bundle install

GitLab Shell 설치#

GitLab Shell은 GitLab을 위해 특별히 개발된 SSH 접근 및 리포지터리 관리 소프트웨어입니다.

# Run the installation task for gitlab-shell:
sudo -u git -H bundle exec rake gitlab:shell:install RAILS_ENV=production

# By default, the gitlab-shell config is generated from your main GitLab config.
# You can review (and modify) the gitlab-shell config as follows:
sudo -u git -H editor /home/git/gitlab-shell/config.yml

HTTPS를 사용하려면 추가 단계를 위해 HTTPS 사용하기를 참조하세요.

호스트명이 올바른 DNS 레코드나 /etc/hosts의 추가 줄 ("127.0.0.1 hostname")로 머신 자체에서 해석될 수 있는지 확인하세요. 예를 들어, 리버스 프록시 뒤에 GitLab을 설정한 경우 이것이 필요할 수 있습니다. 호스트명을 해석할 수 없으면 최종 설치 확인이 Check GitLab API access: FAILED. code: 401로 실패하고 커밋 푸시가 [remote rejected] master -> master (hook declined)로 거부됩니다.

GitLab Workhorse 설치#

GitLab-Workhorse는 GNU Make를 사용합니다. 다음 명령어는 권장 위치인 /home/git/gitlab-workhorse에 GitLab-Workhorse를 설치합니다.

sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]" RAILS_ENV=production

다른 Git 리포지터리를 추가 파라미터로 제공하여 지정할 수 있습니다:

sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse,https://example.com/gitlab-workhorse.git]" RAILS_ENV=production

Enterprise Edition에서 GitLab-Elasticsearch-indexer 설치#

GitLab-Elasticsearch-Indexer는 GNU Make를 사용합니다. 다음 명령어는 권장 위치인 /home/git/gitlab-elasticsearch-indexer에 GitLab-Elasticsearch-Indexer를 설치합니다.

sudo -u git -H bundle exec rake "gitlab:indexer:install[/home/git/gitlab-elasticsearch-indexer]" RAILS_ENV=production

다른 Git 리포지터리를 추가 파라미터로 제공하여 지정할 수 있습니다:

sudo -u git -H bundle exec rake "gitlab:indexer:install[/home/git/gitlab-elasticsearch-indexer,https://example.com/gitlab-elasticsearch-indexer.git]" RAILS_ENV=production

소스 코드는 먼저 첫 번째 파라미터로 지정된 경로로 가져옵니다. 그런 다음 bin 디렉터리 아래에 바이너리가 빌드됩니다. 그런 다음 해당 바이너리를 가리키도록 gitlab.ymlproduction -> elasticsearch -> indexer_path 설정을 업데이트해야 합니다.

GitLab Pages 설치#

GitLab Pages는 GNU Make를 사용합니다. 이 단계는 선택 사항이며 GitLab 내에서 정적 사이트를 호스팅하려는 경우에만 필요합니다. 다음 명령어는 /home/git/gitlab-pages에 GitLab Pages를 설치합니다. 추가 설정 단계는 GitLab Pages 데몬이 여러 다른 방법으로 실행될 수 있으므로 GitLab 버전에 맞는 관리 가이드를 참조하세요.

cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-pages.git
cd gitlab-pages
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
sudo -u git -H make

Gitaly 설치#

# Create and restrict access to the git repository data directory
sudo install -d -o git -m 0700 /home/git/repositories

# Fetch Gitaly source with Git and compile with Go
cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories]" RAILS_ENV=production

다른 Git 리포지터리를 추가 파라미터로 제공하여 지정할 수 있습니다:

sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories,https://example.com/gitaly.git]" RAILS_ENV=production

다음으로 Gitaly가 설정되어 있는지 확인합니다:

# Restrict Gitaly socket access
sudo chmod 0700 /home/git/gitlab/tmp/sockets/private
sudo chown git /home/git/gitlab/tmp/sockets/private

# If you are using non-default settings, you need to update config.toml
cd /home/git/gitaly
sudo -u git -H editor config.toml

Gitaly 설정에 대한 자세한 내용은 Gitaly 문서를 참조하세요.

서비스 설치#

GitLab은 널리 지원되고 이식성이 높은 SysV init 스크립트를 항상 지원해 왔지만, 이제 systemd가 서비스 감시의 표준이며 모든 주요 Linux 배포판에서 사용됩니다. 자동 재시작, 더 나은 샌드박싱 및 리소스 제어의 혜택을 받기 위해 가능한 경우 네이티브 systemd 서비스를 사용해야 합니다.

systemd 유닛 설치#

systemd를 init으로 사용하는 경우 이 단계를 사용하세요. 그렇지 않으면 SysV init 스크립트 단계를 따르세요.

서비스를 복사하고 systemd가 인식할 수 있도록 systemctl daemon-reload를 실행합니다:

cd /home/git/gitlab
sudo mkdir -p /usr/local/lib/systemd/system
sudo cp lib/support/systemd/* /usr/local/lib/systemd/system/
sudo systemctl daemon-reload

GitLab에서 제공하는 유닛은 Redis와 PostgreSQL을 어디서 실행하는지에 대한 가정을 거의 하지 않습니다.

GitLab을 다른 디렉터리에 설치하거나 기본값 이외의 사용자로 설치한 경우, 유닛에서도 이 값들을 변경해야 합니다.

예를 들어, GitLab과 동일한 머신에서 Redis와 PostgreSQL을 실행하는 경우 다음을 수행해야 합니다:

Puma 서비스 편집:

sudo systemctl edit gitlab-puma.service

열리는 편집기에서 다음을 추가하고 파일을 저장합니다:

[Unit]
Wants=redis-server.service postgresql.service
After=redis-server.service postgresql.service

Sidekiq 서비스 편집:

sudo systemctl edit gitlab-sidekiq.service

다음을 추가하고 파일을 저장합니다:

[Unit]
Wants=redis-server.service postgresql.service
After=redis-server.service postgresql.service

systemctl edit/etc/systemd/system/<유닛 이름>.d/override.conf에 드롭인 구성 파일을 설치하므로, 나중에 유닛 파일을 업데이트할 때 로컬 구성을 덮어쓰지 않습니다. 드롭인 구성 파일을 분리하려면 /etc/systemd/system/<유닛 이름>.d/ 아래의 .conf 파일에 이전 스니펫을 추가할 수 있습니다.

(systemctl edit을 사용하지 않고) 유닛 파일을 수동으로 변경하거나 드롭인 구성 파일을 추가한 경우, 변경 사항이 적용되도록 다음 명령어를 실행합니다:

sudo systemctl daemon-reload

부팅 시 GitLab이 시작되도록 설정합니다:

sudo systemctl enable gitlab.target

SysV init 스크립트 설치#

SysV init 스크립트를 사용하는 경우 이 단계를 사용하세요. systemd를 사용하는 경우 systemd 유닛 단계를 따르세요.

init 스크립트를 다운로드합니다 (/etc/init.d/gitlab):

cd /home/git/gitlab
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab

기본값이 아닌 폴더나 사용자로 설치하는 경우 기본값 파일을 복사하고 편집합니다:

sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab

GitLab을 다른 디렉터리에 설치하거나 기본값 이외의 사용자로 설치한 경우, /etc/default/gitlab에서 이 설정을 변경해야 합니다. 업그레이드 시 변경되기 때문에 /etc/init.d/gitlab은 편집하지 마세요.

부팅 시 GitLab이 시작되도록 설정합니다:

sudo update-rc.d gitlab defaults 21
# or if running this on a machine running systemd
sudo systemctl daemon-reload
sudo systemctl enable gitlab.service

Logrotate 설정#

sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

Gitaly 시작#

다음 섹션을 위해 Gitaly가 실행 중이어야 합니다.

systemd를 사용하여 Gitaly를 시작하려면:

sudo systemctl start gitlab-gitaly.service

SysV용으로 Gitaly를 수동으로 시작하려면:

gitlab_path=/home/git/gitlab
gitaly_path=/home/git/gitaly

sudo -u git -H sh -c "$gitlab_path/bin/daemon_with_pidfile $gitlab_path/tmp/pids/gitaly.pid \
  $gitaly_path/_build/bin/gitaly $gitaly_path/config.toml >> $gitlab_path/log/gitaly.log 2>&1 &"

데이터베이스 초기화 및 고급 기능 활성화#

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
# Type 'yes' to create the database tables.

# or you can skip the question by adding force=yes
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production force=yes

# When done, you see 'Administrator account created:'

환경 변수 GITLAB_ROOT_PASSWORDGITLAB_ROOT_EMAIL로 관리자/root 비밀번호와 이메일을 설정할 수 있습니다. 비밀번호를 설정하지 않으면 (기본값으로 설정된 경우) 설치가 완료되고 서버에 처음 로그인할 때까지 GitLab을 공개 인터넷에 노출하지 마세요. 첫 번째 로그인 시 기본 비밀번호를 변경하도록 강제됩니다. Enterprise Edition 구독은 GITLAB_ACTIVATION_CODE 환경 변수로 활성화 코드를 제공하여 이 시점에 활성화할 수 있습니다.

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword GITLAB_ROOT_EMAIL=youremail GITLAB_ACTIVATION_CODE=yourcode

secrets.yml 보안#

secrets.yml 파일은 세션 및 보안 변수의 암호화 키를 저장합니다. secrets.yml을 안전한 곳에 백업하되, 데이터베이스 백업과 같은 곳에 저장하지 마세요. 그렇지 않으면 백업 중 하나가 유출될 경우 시크릿이 노출됩니다.

애플리케이션 상태 확인#

GitLab과 환경이 올바르게 구성되었는지 확인합니다:

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

에셋 컴파일#

sudo -u git -H yarn install --production --pure-lockfile
sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production

rakeJavaScript heap out of memory 오류로 실패하면, 다음과 같이 NODE_OPTIONS를 설정하여 실행해 보세요.

sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production NODE_OPTIONS="--max_old_space_size=4096"

GitLab 인스턴스 시작#

# For systems running systemd
sudo systemctl start gitlab.target

# For systems running SysV init
sudo service gitlab start

10. NGINX#

NGINX는 GitLab에서 공식적으로 지원하는 웹 서버입니다. NGINX를 웹 서버로 사용할 수 없거나 사용하지 않으려면 GitLab 레시피를 참조하세요.

설치#

sudo apt-get install -y nginx

사이트 설정#

사이트 설정 예제를 복사합니다:

sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

설정에 맞게 구성 파일을 편집해야 합니다. 특히 git 사용자 이외의 사용자로 설치하는 경우 GitLab 경로가 일치하는지 확인하세요:

# Change YOUR_SERVER_FQDN to the fully-qualified
# domain name of your host serving GitLab.
#
# Remember to match your paths to GitLab, especially
# if installing for a user other than 'git'.
#
# If using Ubuntu default nginx install:
# either remove the default_server from the listen line
# or else sudo rm -f /etc/nginx/sites-enabled/default
sudo editor /etc/nginx/sites-available/gitlab

GitLab Pages를 활성화하려면 별도의 NGINX 설정이 필요합니다. 필요한 설정에 대한 자세한 내용은 GitLab Pages 관리 가이드를 참조하세요.

HTTPS를 사용하려면 gitlab NGINX 설정을 gitlab-ssl로 교체하세요. HTTPS 설정에 대한 자세한 내용은 HTTPS 사용하기를 참조하세요.

NGINX가 GitLab-Workhorse 소켓을 읽을 수 있도록 하려면, www-data 사용자가 GitLab 사용자가 소유한 소켓을 읽을 수 있어야 합니다. 이는 소켓이 world-readable인 경우, 예를 들어 기본값인 0755 권한을 가지고 있는 경우 달성됩니다. www-data도 상위 디렉터리 목록을 볼 수 있어야 합니다.

설정 테스트#

다음 명령어로 gitlab 또는 gitlab-ssl NGINX 설정 파일을 검증합니다:

sudo nginx -t

syntax is okaytest is successful 메시지를 받아야 합니다. 오류 메시지가 표시되면 제공된 오류 메시지에 표시된 대로 gitlab 또는 gitlab-ssl NGINX 구성 파일에서 오타를 확인하세요.

설치된 버전이 1.12.1보다 최신인지 확인합니다:

nginx -v

버전이 낮으면 다음과 같은 오류가 발생할 수 있습니다:

nginx: [emerg] unknown "start$temp=[filtered]$rest" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

재시작#

# For systems running systemd
sudo systemctl restart nginx.service

# For systems running SysV init
sudo service nginx restart

설치 후 작업#

애플리케이션 상태 재확인#

놓친 것이 없는지 더 철저한 확인을 실행합니다:

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

모든 항목이 녹색이라면, GitLab 설치를 성공적으로 완료한 것을 축하합니다!

확인 명령어 출력에서 프로젝트 이름을 생략하려면 `gitlab:check`에 `SANITIZE=true` 환경 변수를 제공하세요.

초기 로그인#

웹 브라우저에서 YOUR_SERVER를 방문하여 처음으로 GitLab에 로그인하세요.

설정 중 root 비밀번호를 제공하지 않은 경우, 초기 관리자 계정의 비밀번호를 설정하기 위한 비밀번호 재설정 화면으로 리디렉션됩니다. 원하는 비밀번호를 입력하면 로그인 화면으로 다시 리디렉션됩니다.

기본 계정의 사용자명은 root입니다. 이전에 생성한 비밀번호를 입력하여 로그인하세요. 로그인 후 원하면 사용자명을 변경할 수 있습니다.

즐기세요!

다음을 사용할 때 GitLab을 시작 및 중지하려면:

  • systemd 유닛: sudo systemctl start gitlab.target 또는 sudo systemctl stop gitlab.target을 사용합니다.

  • SysV init 스크립트: sudo service gitlab start 또는 sudo service gitlab stop을 사용합니다.

권장 다음 단계#

설치 완료 후, 인증 옵션과 신규 사용자 계정 제한 사항을 포함한 권장 다음 단계를 고려해보세요.

고급 설정 팁#

상대 URL 지원#

상대 URL로 GitLab을 설정하는 방법에 대한 자세한 내용은 상대 URL 문서를 참조하세요.

HTTPS 사용하기#

GitLab에 HTTPS를 사용하려면:

  • gitlab.yml에서:

섹션 1의 port 옵션을 443으로 설정합니다.

  • 섹션 1의 https 옵션을 true로 설정합니다.

  • GitLab Shell의 config.yml에서:

gitlab_url 옵션을 GitLab의 HTTPS 엔드포인트로 설정합니다 (예: https://git.example.com).

  • ca_file 또는 ca_path 옵션을 사용하여 인증서를 설정합니다.

  • gitlab 설정 대신 gitlab-ssl NGINX 예제 설정을 사용합니다.

YOUR_SERVER_FQDN을 업데이트합니다.

  • ssl_certificatessl_certificate_key를 업데이트합니다.

  • 구성 파일을 검토하고 다른 보안 및 성능 향상 기능 적용을 고려합니다.

자체 서명 인증서 사용은 권장되지 않습니다. 반드시 사용해야 한다면 표준 지침에 따라 자체 서명 SSL 인증서를 생성하세요:

mkdir -p /etc/nginx/ssl/
cd /etc/nginx/ssl/
sudo openssl req -newkey rsa:2048 -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key
sudo chmod o-r gitlab.key

이메일 답장 활성화#

설정 방법에 대한 자세한 내용은 "이메일 답장" 문서를 참조하세요.

LDAP 인증#

config/gitlab.yml에서 LDAP 인증을 설정할 수 있습니다. 이 파일을 편집한 후 GitLab을 재시작하세요.

커스텀 OmniAuth 공급자 사용하기#

OmniAuth 통합 문서를 참조하세요.

프로젝트 빌드#

GitLab은 프로젝트를 빌드할 수 있습니다. 이 기능을 활성화하려면 빌드를 수행할 runner가 필요합니다. 설치 방법은 GitLab Runner 섹션을 참조하세요.

신뢰할 수 있는 프록시 추가#

별도의 머신에서 리버스 프록시를 사용하는 경우 프록시를 신뢰할 수 있는 프록시 목록에 추가할 수 있습니다. 그렇지 않으면 사용자가 프록시의 IP 주소로 로그인한 것처럼 표시됩니다.

config/gitlab.yml의 섹션 1에 있는 trusted_proxies 옵션을 사용자 정의하여 신뢰할 수 있는 프록시를 추가할 수 있습니다. 파일을 저장하고 변경 사항이 적용되도록 GitLab을 재설정하세요.

URL에서 잘못 인코딩된 문자 문제가 발생하면 리버스 프록시 사용 시 404 Not Found 오류를 참조하세요.

커스텀 Redis 연결#

비표준 포트나 다른 호스트의 Redis 서버에 연결하려면 config/resque.yml 파일을 통해 연결 문자열을 설정할 수 있습니다.

# example
production:
  url: redis://redis.example.tld:6379

소켓을 통해 Redis 서버에 연결하려면 config/resque.yml 파일에서 unix: URL 스킴과 Redis 소켓 파일 경로를 사용하세요.

# example
production:
  url: unix:/path/to/redis/socket

또한 config/resque.yml 파일에서 환경 변수를 사용할 수 있습니다:

# example
production:
  url: <%= ENV.fetch('GITLAB_REDIS_URL') %>

커스텀 SSH 연결#

비표준 포트에서 SSH를 실행하는 경우 GitLab 사용자의 SSH 구성을 변경해야 합니다.

# Add to /home/git/.ssh/config
host localhost          # Give your setup a name (here: override localhost)
    user git            # Your remote git user
    port 2222           # Your port number
    hostname 127.0.0.1; # Your server name or IP

config/gitlab.yml 파일에서 해당 옵션(예: ssh_user, ssh_host, admin_uri)도 변경해야 합니다.

추가 마크업 스타일#

항상 지원되는 Markdown 스타일 외에도 GitLab에서 표시할 수 있는 다른 리치 텍스트 파일이 있습니다. 하지만 그렇게 하려면 의존성을 설치해야 할 수 있습니다. 자세한 내용은 github-markup gem README를 참조하세요.

Prometheus 서버 설정#

config/gitlab.yml에서 Prometheus 서버를 설정할 수 있습니다:

# example
prometheus:
  enabled: true
  server_address: '10.1.2.3:9090'

문제 해결#

메시지: 빈 리포지터리를 클론한 것 같습니다.#

GitLab이 호스팅하는 리포지터리를 클론하려고 할 때 이 메시지가 표시되면, 오래된 NGINX나 Apache 설정, 또는 누락되거나 잘못 설정된 GitLab Workhorse 인스턴스 때문일 가능성이 높습니다. Go 설치, GitLab Workhorse 설치, 그리고 NGINX 설정이 올바른지 다시 확인하세요.

google-protobuf 오류: LoadError: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.14' not found#

이 오류는 일부 플랫폼에서 google-protobuf 젬의 특정 버전에서 발생할 수 있습니다. 해결 방법은 이 젬의 소스 전용 버전을 설치하는 것입니다.

먼저, GitLab 설치에 필요한 google-protobuf의 정확한 버전을 찾아야 합니다:

cd /home/git/gitlab

# Only one of the following two commands will print something. It
# will look like: * google-protobuf (3.2.0)
bundle list | grep google-protobuf
bundle check | grep google-protobuf

다음 명령어에서 3.2.0은 예시로 사용되었습니다. 이전에 찾은 버전 번호로 교체하세요:

cd /home/git/gitlab
sudo -u git -H gem install google-protobuf --version 3.2.0 --platform ruby

마지막으로 google-protobuf가 올바르게 로드되는지 테스트할 수 있습니다. 다음은 OK를 출력해야 합니다.

sudo -u git -H bundle exec ruby -rgoogle/protobuf -e 'puts :OK'

gem install 명령어가 실패하면 OS의 개발자 도구를 설치해야 할 수 있습니다.

Debian/Ubuntu의 경우:

sudo apt-get install build-essential libgmp-dev

RedHat/CentOS의 경우:

sudo yum groupinstall 'Development Tools'

GitLab 에셋 컴파일 오류#

에셋을 컴파일하는 동안 다음과 같은 오류 메시지가 표시될 수 있습니다:

Killed
error Command failed with exit code 137.

이 오류는 메모리 부족 컨테이너를 Yarn이 종료할 때 발생할 수 있습니다. 이를 해결하려면:

시스템 메모리를 최소 8 GB 이상으로 늘리세요.

다음 명령어를 실행하여 에셋을 정리합니다:

sudo -u git -H bundle exec rake gitlab:assets:clean RAILS_ENV=production NODE_ENV=production

충돌을 해결하기 위해 yarn 명령어를 다시 실행합니다:

sudo -u git -H yarn install --production --pure-lockfile

에셋을 다시 컴파일합니다:

sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production

소스 코드 직접 컴파일 설치

GitLab v19.1
Tier: Premium, Ultimate
Offering: GitLab Self-Managed
원문 보기
요약

- Offering: GitLab Self-Managed 이 문서는 소스 파일을 사용하여 프로덕션 GitLab 서버를 설정하는 공식 설치 가이드입니다. 이 가이드는 많은 경우를 다루고 필요한 모든 명령어를 포함하기 때문에 내용이 깁니다.

  - 
  Tier: Free, Premium, Ultimate

- Offering: GitLab Self-Managed

이 문서는 소스 파일을 사용하여 프로덕션 GitLab 서버를 설정하는 공식 설치 가이드입니다. Debian/Ubuntu 운영 체제용으로 작성되었으며 해당 환경에서 테스트되었습니다. 하드웨어 및 운영 체제 요구 사항은 requirements.md를 참조하세요. RHEL/CentOS에 설치하려면 Linux 패키지를 사용하세요. 다른 설치 옵션에 대해서는 주요 설치 페이지를 참조하세요.

이 가이드는 많은 경우를 다루고 필요한 모든 명령어를 포함하기 때문에 내용이 깁니다. 아래 단계들은 정상 동작하는 것으로 확인되었습니다. 이 가이드에서 벗어날 때는 주의하세요. GitLab이 환경에 대해 세우는 가정을 위반하지 않도록 하세요. 예를 들어, 디렉터리 위치를 변경하거나 잘못된 사용자로 서비스를 실행하는 경우 권한 문제가 발생하는 경우가 많습니다.

이 가이드에서 버그나 오류를 발견하면, 기여 가이드를 따라 머지 리퀘스트를 제출하세요.

Linux 패키지 설치 고려하기#

소스 코드 직접 컴파일 설치는 작업량이 많고 오류가 발생하기 쉽기 때문에, 빠르고 안정적인 Linux 패키지 설치 (deb/rpm) 방식을 강력히 권장합니다.

Linux 패키지가 더 안정적인 이유 중 하나는, GitLab 프로세스가 충돌할 경우 runit을 사용하여 재시작하기 때문입니다. 사용량이 많은 GitLab 인스턴스에서는 Sidekiq 백그라운드 워커의 메모리 사용량이 시간이 지남에 따라 증가합니다. Linux 패키지는 메모리 사용량이 너무 많아질 경우 Sidekiq이 정상적으로 종료되도록 허용하여 이 문제를 해결합니다. 정상 종료 후 runit은 Sidekiq이 실행되지 않는 것을 감지하고 다시 시작합니다. 소스 코드 직접 컴파일 설치는 프로세스 감시에 runit을 사용하지 않으므로, Sidekiq을 종료할 수 없어 메모리 사용량이 시간이 지남에 따라 증가합니다.

설치할 버전 선택#

설치하려는 GitLab 버전의 브랜치(버전)에서 이 설치 가이드를 확인하세요 (예: 16-0-stable). GitLab의 좌측 상단 모서리(메뉴 바 아래)에 있는 버전 드롭다운 목록에서 브랜치를 선택할 수 있습니다.

가장 높은 번호의 안정 브랜치가 불명확한 경우, GitLab 블로그에서 버전별 설치 가이드 링크를 확인하세요.

소프트웨어 요구 사항#

소프트웨어 최소 버전 비고
Ruby 3.2.x GitLab 16.7부터 17.4까지는 Ruby 3.1이 필요합니다. GitLab 17.5 이상에서는 Ruby 3.2가 필요합니다. 표준 MRI Ruby 구현을 사용해야 합니다. JRuby와 Rubinius도 좋지만, GitLab은 네이티브 확장이 있는 여러 Gem이 필요합니다.
RubyGems 3.5.x 특정 RubyGems 버전이 필요한 것은 아니지만, 알려진 성능 향상 혜택을 받기 위해 업데이트하는 것이 좋습니다.
Go 1.22.x GitLab 17.1 이상에서는 Go 1.22 이상이 필요합니다.
Git 2.47.x GitLab 17.7 이상에서는 Git 2.47.x 이상이 필요합니다. Gitaly에서 제공하는 Git 버전을 사용해야 합니다.
Node.js 20.13.x GitLab 17.0 이상에서는 Node.js 20.13 이상이 필요합니다.
PostgreSQL 16.x GitLab 18.0 이상에서는 PostgreSQL 16 이상이 필요합니다.

GitLab 디렉터리 구조#

설치 단계를 따라가면서 다음 디렉터리들이 생성됩니다:

|-- home
|   |-- git
|       |-- .ssh
|       |-- gitlab
|       |-- gitlab-shell
|       |-- repositories
  • /home/git/.ssh - OpenSSH 설정을 포함합니다. 특히 GitLab Shell이 관리하는 authorized_keys 파일이 있습니다.

  • /home/git/gitlab - GitLab 핵심 소프트웨어입니다.

  • /home/git/gitlab-shell - GitLab의 핵심 애드온 컴포넌트입니다. SSH 클로닝 및 기타 기능을 유지 관리합니다.

  • /home/git/repositories - 네임스페이스별로 구성된 모든 프로젝트의 베어(bare) 리포지터리입니다. 이 디렉터리는 모든 프로젝트의 Git 리포지터리가 푸시/풀되는 곳입니다. 이 영역에는 프로젝트의 중요한 데이터가 포함되어 있습니다. 백업을 유지하세요.

리포지터리의 기본 위치는 GitLab의 config/gitlab.yml과 GitLab Shell의 config.yml에서 설정할 수 있습니다.

지금 이 디렉터리들을 수동으로 생성할 필요가 없으며, 그렇게 하면 나중에 설치 시 오류가 발생할 수 있습니다.

설치 워크플로우#

GitLab 설치는 다음 컴포넌트들을 설정하는 과정으로 구성됩니다:

1. 패키지 및 의존성#

sudo#

sudo는 Debian에 기본적으로 설치되어 있지 않습니다. 시스템을 최신 상태로 업데이트하고 설치하세요.

# run as root!
apt-get update -y
apt-get upgrade -y
apt-get install sudo -y

빌드 의존성#

필요한 패키지를 설치하세요 (Ruby 및 Ruby 젬의 네이티브 확장을 컴파일하는 데 필요합니다):

sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libre2-dev \
  libreadline-dev libncurses5-dev libffi-dev curl openssh-server libxml2-dev libxslt-dev \
  libcurl4-openssl-dev libicu-dev libkrb5-dev logrotate rsync python3-docutils pkg-config cmake \
  runit-systemd
GitLab은 OpenSSL 버전 1.1이 필요합니다. Linux 배포판에 다른 버전의 OpenSSL이 포함된 경우,

1.1을 수동으로 설치해야 할 수도 있습니다.

Git#

다음과 같은 이유로 Gitaly에서 제공하는 Git 버전을 사용해야 합니다:

  • GitLab에서 요구하는 버전을 항상 유지합니다.

  • 정상적인 운영에 필요한 커스텀 패치가 포함될 수 있습니다.

필요한 의존성을 설치합니다:

sudo apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev libpcre2-dev build-essential git-core

Gitaly 리포지터리를 클론하고 Git을 컴파일합니다. <X-Y-stable>을 설치하려는 GitLab 버전에 맞는 안정 브랜치로 교체하세요. 예를 들어, GitLab 16.7을 설치하려면 브랜치 이름 16-7-stable을 사용합니다:

git clone https://gitlab.com/gitlab-org/gitaly.git -b <X-Y-stable> /tmp/gitaly
cd /tmp/gitaly
sudo make git GIT_PREFIX=/usr/local

선택적으로, 시스템 Git 및 의존성을 제거할 수 있습니다:

sudo apt remove -y git-core
sudo apt autoremove

나중에 config/gitlab.yml을 편집할 때, Git 경로를 변경하는 것을 기억하세요:

변경 전:

git:
  bin_path: /usr/bin/git

변경 후:

git:
  bin_path: /usr/local/bin/git

GraphicsMagick#

커스텀 파비콘이 작동하려면 GraphicsMagick이 설치되어 있어야 합니다.

sudo apt-get install -y graphicsmagick

메일 서버#

메일 알림을 수신하려면 메일 서버를 설치해야 합니다. 기본적으로 Debian에는 exim4가 포함되어 있지만 Ubuntu와 달리 이는 문제가 있습니다. 권장 메일 서버는 postfix이며 다음으로 설치할 수 있습니다:

sudo apt-get install -y postfix

그런 다음 Internet Site를 선택하고 Enter를 눌러 호스트명을 확인합니다.

ExifTool#

GitLab Workhorse는 업로드된 이미지에서 EXIF 데이터를 제거하기 위해 exiftool이 필요합니다.

sudo apt-get install -y libimage-exiftool-perl

2. Ruby#

GitLab을 실행하려면 Ruby 인터프리터가 필요합니다. 최소 Ruby 요구 사항은 요구 사항 섹션을 참조하세요.

RVM, rbenv, chruby 같은 Ruby 버전 관리자는 GitLab에서 진단하기 어려운 문제를 유발할 수 있습니다. 대신 공식 소스 코드에서 Ruby를 설치해야 합니다.

3. RubyGems#

경우에 따라 Ruby에 번들된 것보다 최신 버전의 RubyGems가 필요합니다.

특정 버전으로 업데이트하려면:

gem update --system 3.4.12

또는 최신 버전으로:

gem update --system

4. Go#

GitLab에는 Go로 작성된 여러 데몬이 있습니다. GitLab을 설치하려면 Go 컴파일러를 설치해야 합니다. 다음 지침은 64비트 Linux를 사용하는 것으로 가정합니다. 다른 플랫폼의 다운로드는 Go 다운로드 페이지에서 찾을 수 있습니다.

# Remove former Go installation folder
sudo rm -rf /usr/local/go

curl --remote-name --location --progress-bar "https://go.dev/dl/go1.22.5.linux-amd64.tar.gz"
echo '904b924d435eaea086515bc63235b192ea441bd8c9b198c507e85009e6e4c7f0  go1.22.5.linux-amd64.tar.gz' | shasum -a256 -c - && \
  sudo tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
sudo ln -sf /usr/local/go/bin/{go,gofmt} /usr/local/bin/
rm go1.22.5.linux-amd64.tar.gz

5. Node#

GitLab은 JavaScript 에셋을 컴파일하기 위해 Node를, JavaScript 의존성을 관리하기 위해 Yarn을 사용합니다. 현재 최소 요구 사항은 다음과 같습니다:

  • node 20.x 릴리스 (v20.13.0 이상). Node.js의 다른 LTS 버전으로도 에셋을 빌드할 수 있을 수 있지만, Node.js 20.x만 보장됩니다.

  • yarn = v1.22.x (Yarn 2는 아직 지원되지 않습니다)

많은 배포판에서 공식 패키지 리포지터리에서 제공하는 버전이 오래되어 있으므로, 다음 명령어를 통해 설치해야 합니다:

# install node v20.x
curl --location "https://deb.nodesource.com/setup_20.x" | sudo bash -
sudo apt-get install -y nodejs

npm install --global yarn

이 단계에서 문제가 발생하면 nodeyarn의 공식 웹사이트를 방문하세요.

6. 시스템 사용자#

GitLab을 위한 git 사용자를 생성합니다:

sudo adduser --disabled-login --gecos 'GitLab' git

7. 데이터베이스#

PostgreSQL만 지원됩니다.

GitLab 18.0 이상에서는 PostgreSQL 16+가 필요합니다.

데이터베이스 패키지를 설치합니다.

Ubuntu 22.04 이상의 경우:

sudo apt install -y postgresql postgresql-client libpq-dev postgresql-contrib

Ubuntu 20.04 이하의 경우, 사용 가능한 PostgreSQL이 최소 버전 요구 사항을 충족하지 않습니다. PostgreSQL 리포지터리를 추가해야 합니다:

sudo curl --fail --silent --show-error --output /etc/apt/keyrings/postgresql.asc \
          --url "https://www.postgresql.org/media/keys/ACCC4CF8.asc"
echo "deb [ signed-by=/etc/apt/keyrings/postgresql.asc ] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" |
     sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get -y install postgresql-16

설치하려는 GitLab 버전에서 지원하는 PostgreSQL 버전인지 확인합니다:

psql --version

PostgreSQL 서비스를 시작하고 서비스가 실행 중인지 확인합니다:

sudo service postgresql start
sudo service postgresql status

GitLab용 데이터베이스 사용자를 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE USER git CREATEDB;"

pg_trgm 확장을 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"

btree_gist 확장을 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"

plpgsql 확장을 생성합니다:

sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS plpgsql;"

GitLab 프로덕션 데이터베이스를 생성하고 해당 데이터베이스에 모든 권한을 부여합니다:

sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;"

새 사용자로 새 데이터베이스에 연결을 시도합니다:

sudo -u git -H psql -d gitlabhq_production

pg_trgm 확장이 활성화되어 있는지 확인합니다:

SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'pg_trgm'
AND installed_version IS NOT NULL;

확장이 활성화된 경우 다음과 같은 출력이 생성됩니다:

enabled
---------
 t
(1 row)

btree_gist 확장이 활성화되어 있는지 확인합니다:

SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'btree_gist'
AND installed_version IS NOT NULL;

확장이 활성화된 경우 다음과 같은 출력이 생성됩니다:

enabled
---------
 t
(1 row)

plpgsql 확장이 활성화되어 있는지 확인합니다:

SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'plpgsql'
AND installed_version IS NOT NULL;

확장이 활성화된 경우 다음과 같은 출력이 생성됩니다:

enabled
---------
 t
(1 row)

데이터베이스 세션을 종료합니다:

gitlabhq_production> \q

8. Redis#

최소 Redis 요구 사항은 요구 사항 페이지를 참조하세요.

다음으로 Redis를 설치합니다:

sudo apt-get install redis-server

설치가 완료되면 Redis를 설정할 수 있습니다:

# Configure redis to use sockets
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig

# Disable Redis listening on TCP by setting 'port' to 0
sudo sed 's/^port .*/port 0/' /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf

# Enable Redis socket for default Debian / Ubuntu path
echo 'unixsocket /var/run/redis/redis.sock' | sudo tee -a /etc/redis/redis.conf

# Grant permission to the socket to all members of the redis group
echo 'unixsocketperm 770' | sudo tee -a /etc/redis/redis.conf

# Add git to the redis group
sudo usermod -aG redis git

systemd로 Redis 감시하기#

배포판이 systemd init을 사용하고 다음 명령어의 출력이 notify인 경우, 아무 변경도 하지 않아도 됩니다:

systemctl show --value --property=Type redis-server.service

출력이 notify아닌 경우 다음을 실행합니다:

# Configure Redis to not daemonize, but be supervised by systemd instead and disable the pidfile
sudo sed -i \
         -e 's/^daemonize yes$/daemonize no/' \
         -e 's/^supervised no$/supervised systemd/' \
         -e 's/^pidfile/# pidfile/' /etc/redis/redis.conf
sudo chown redis:redis /etc/redis/redis.conf

# Make the same changes to the systemd unit file
sudo mkdir -p /etc/systemd/system/redis-server.service.d
sudo tee /etc/systemd/system/redis-server.service.d/10fix_type.conf <

Redis 비감시 실행#

시스템이 SysV init을 사용하는 경우 다음 명령어를 실행합니다:

# Create the directory which contains the socket
sudo mkdir -p /var/run/redis
sudo chown redis:redis /var/run/redis
sudo chmod 755 /var/run/redis

# Persist the directory which contains the socket, if applicable
if [ -d /etc/tmpfiles.d ]; then
  echo 'd  /var/run/redis  0755  redis  redis  10d  -' | sudo tee -a /etc/tmpfiles.d/redis.conf
fi

# Activate the changes to redis.conf
sudo service redis-server restart

9. GitLab#

# We'll install GitLab into the home directory of the user "git"
cd /home/git

소스 클론#

Community Edition 클론:

# Clone GitLab repository
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-foss.git -b <X-Y-stable> gitlab

Enterprise Edition 클론:

# Clone GitLab repository
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab.git -b <X-Y-stable-ee> gitlab

<X-Y-stable>을 설치하려는 버전에 맞는 안정 브랜치로 교체하세요. 예를 들어, 11.8을 설치하려면 브랜치 이름 11-8-stable을 사용합니다.

최신 "bleeding edge" 버전을 원한다면 `<X-Y-stable>`을 `master`로 변경할 수 있지만, 프로덕션 서버에는 절대 `master`를 설치하지 마세요!

설정하기#

# Go to GitLab installation folder
cd /home/git/gitlab

# Copy the example GitLab config
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

# Update GitLab config file, follow the directions at top of the file
sudo -u git -H editor config/gitlab.yml

# Copy the example secrets file
sudo -u git -H cp config/secrets.yml.example config/secrets.yml
sudo -u git -H chmod 0600 config/secrets.yml

# Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX,go-w log/
sudo chmod -R u+rwX tmp/

# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories
sudo chmod -R u+rwX tmp/pids/
sudo chmod -R u+rwX tmp/sockets/

# Create the public/uploads/ directory
sudo -u git -H mkdir -p public/uploads/

# Make sure only the GitLab user has access to the public/uploads/ directory
# now that files in public/uploads are served by gitlab-workhorse
sudo chmod 0700 public/uploads

# Change the permissions of the directory where CI job logs are stored
sudo chmod -R u+rwX builds/

# Change the permissions of the directory where CI artifacts are stored
sudo chmod -R u+rwX shared/artifacts/

# Change the permissions of the directory where GitLab Pages are stored
sudo chmod -R ug+rwX shared/pages/

# Copy the example Puma config
sudo -u git -H cp config/puma.rb.example config/puma.rb

# Refer to https://github.com/puma/puma#configuration for more information.
# You should scale Puma workers and threads based on the number of CPU
# cores you have available. You can get that number via the `nproc` command.
sudo -u git -H editor config/puma.rb

# Configure Redis connection settings
sudo -u git -H cp config/resque.yml.example config/resque.yml
sudo -u git -H cp config/cable.yml.example config/cable.yml

# Change the Redis socket path if you are not using the default Debian / Ubuntu configuration
sudo -u git -H editor config/resque.yml config/cable.yml

설정에 맞게 gitlab.ymlpuma.rb 모두 편집하세요.

HTTPS를 사용하려면 추가 단계를 위해 HTTPS 사용하기를 참조하세요.

GitLab DB 설정 구성#

[GitLab 15.9](https://gitlab.com/gitlab-org/gitlab/-/issues/387898)부터 `main:` 섹션만 있는 `database.yml`은 더 이상 사용되지 않습니다.

GitLab 17.0 이상에서는 database.ymlmain:ci: 두 섹션이 반드시 있어야 합니다.

sudo -u git cp config/database.yml.postgresql config/database.yml

# Remove host, username, and password lines from config/database.yml.
# Once modified, the `production` settings will be as follows:
#
#   production:
#     main:
#       adapter: postgresql
#       encoding: unicode
#       database: gitlabhq_production
#     ci:
#       adapter: postgresql
#       encoding: unicode
#       database: gitlabhq_production
#       database_tasks: false
#
sudo -u git -H editor config/database.yml

# Remote PostgreSQL only:
# Update username/password in config/database.yml.
# You only need to adapt the production settings (first part).
# If you followed the database guide then please do as follows:
# Change 'secure password' with the value you have given to $password
# You can keep the double quotes around the password
sudo -u git -H editor config/database.yml

# Uncomment the `ci:` sections in config/database.yml.
# Ensure the `database` value in `ci:` matches the database value in `main:`.

# Make config/database.yml readable to git only
sudo -u git -H chmod o-rwx config/database.yml

database.yml에는 main:ci: 두 섹션이 있어야 합니다. ci: 연결은 동일한 데이터베이스에 연결해야 합니다.

Gem 설치#

Bundler 1.5.2부터 `bundle install -jN` (여기서 `N`은 프로세서 코어 수)을 실행하여 병렬 젬 설치를 즐길 수 있으며, 완료 시간에 측정 가능한 차이가 있습니다 (약 60% 빠름). `nproc`으로 코어 수를 확인하세요. 자세한 내용은 이 [게시물](https://thoughtbot.com/blog/parallel-gem-installing-using-bundler)을 참조하세요.

bundle이 있는지 확인하세요 (bundle -v 실행):

  • >= 1.5.2: 1.5.2에서 일부 문제수정되었기 때문입니다.

  • < 2.x.

젬을 설치하세요 (사용자 인증에 Kerberos를 사용하려면 다음 명령어의 --without 옵션에서 kerberos를 제외하세요):

sudo -u git -H bundle config set --local deployment 'true'
sudo -u git -H bundle config set --local without 'development test kerberos'
sudo -u git -H bundle config path /home/git/gitlab/vendor/bundle
sudo -u git -H bundle install

GitLab Shell 설치#

GitLab Shell은 GitLab을 위해 특별히 개발된 SSH 접근 및 리포지터리 관리 소프트웨어입니다.

# Run the installation task for gitlab-shell:
sudo -u git -H bundle exec rake gitlab:shell:install RAILS_ENV=production

# By default, the gitlab-shell config is generated from your main GitLab config.
# You can review (and modify) the gitlab-shell config as follows:
sudo -u git -H editor /home/git/gitlab-shell/config.yml

HTTPS를 사용하려면 추가 단계를 위해 HTTPS 사용하기를 참조하세요.

호스트명이 올바른 DNS 레코드나 /etc/hosts의 추가 줄 ("127.0.0.1 hostname")로 머신 자체에서 해석될 수 있는지 확인하세요. 예를 들어, 리버스 프록시 뒤에 GitLab을 설정한 경우 이것이 필요할 수 있습니다. 호스트명을 해석할 수 없으면 최종 설치 확인이 Check GitLab API access: FAILED. code: 401로 실패하고 커밋 푸시가 [remote rejected] master -> master (hook declined)로 거부됩니다.

GitLab Workhorse 설치#

GitLab-Workhorse는 GNU Make를 사용합니다. 다음 명령어는 권장 위치인 /home/git/gitlab-workhorse에 GitLab-Workhorse를 설치합니다.

sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]" RAILS_ENV=production

다른 Git 리포지터리를 추가 파라미터로 제공하여 지정할 수 있습니다:

sudo -u git -H bundle exec rake "gitlab:workhorse:install[/home/git/gitlab-workhorse,https://example.com/gitlab-workhorse.git]" RAILS_ENV=production

Enterprise Edition에서 GitLab-Elasticsearch-indexer 설치#

GitLab-Elasticsearch-Indexer는 GNU Make를 사용합니다. 다음 명령어는 권장 위치인 /home/git/gitlab-elasticsearch-indexer에 GitLab-Elasticsearch-Indexer를 설치합니다.

sudo -u git -H bundle exec rake "gitlab:indexer:install[/home/git/gitlab-elasticsearch-indexer]" RAILS_ENV=production

다른 Git 리포지터리를 추가 파라미터로 제공하여 지정할 수 있습니다:

sudo -u git -H bundle exec rake "gitlab:indexer:install[/home/git/gitlab-elasticsearch-indexer,https://example.com/gitlab-elasticsearch-indexer.git]" RAILS_ENV=production

소스 코드는 먼저 첫 번째 파라미터로 지정된 경로로 가져옵니다. 그런 다음 bin 디렉터리 아래에 바이너리가 빌드됩니다. 그런 다음 해당 바이너리를 가리키도록 gitlab.ymlproduction -> elasticsearch -> indexer_path 설정을 업데이트해야 합니다.

GitLab Pages 설치#

GitLab Pages는 GNU Make를 사용합니다. 이 단계는 선택 사항이며 GitLab 내에서 정적 사이트를 호스팅하려는 경우에만 필요합니다. 다음 명령어는 /home/git/gitlab-pages에 GitLab Pages를 설치합니다. 추가 설정 단계는 GitLab Pages 데몬이 여러 다른 방법으로 실행될 수 있으므로 GitLab 버전에 맞는 관리 가이드를 참조하세요.

cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-pages.git
cd gitlab-pages
sudo -u git -H git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
sudo -u git -H make

Gitaly 설치#

# Create and restrict access to the git repository data directory
sudo install -d -o git -m 0700 /home/git/repositories

# Fetch Gitaly source with Git and compile with Go
cd /home/git/gitlab
sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories]" RAILS_ENV=production

다른 Git 리포지터리를 추가 파라미터로 제공하여 지정할 수 있습니다:

sudo -u git -H bundle exec rake "gitlab:gitaly:install[/home/git/gitaly,/home/git/repositories,https://example.com/gitaly.git]" RAILS_ENV=production

다음으로 Gitaly가 설정되어 있는지 확인합니다:

# Restrict Gitaly socket access
sudo chmod 0700 /home/git/gitlab/tmp/sockets/private
sudo chown git /home/git/gitlab/tmp/sockets/private

# If you are using non-default settings, you need to update config.toml
cd /home/git/gitaly
sudo -u git -H editor config.toml

Gitaly 설정에 대한 자세한 내용은 Gitaly 문서를 참조하세요.

서비스 설치#

GitLab은 널리 지원되고 이식성이 높은 SysV init 스크립트를 항상 지원해 왔지만, 이제 systemd가 서비스 감시의 표준이며 모든 주요 Linux 배포판에서 사용됩니다. 자동 재시작, 더 나은 샌드박싱 및 리소스 제어의 혜택을 받기 위해 가능한 경우 네이티브 systemd 서비스를 사용해야 합니다.

systemd 유닛 설치#

systemd를 init으로 사용하는 경우 이 단계를 사용하세요. 그렇지 않으면 SysV init 스크립트 단계를 따르세요.

서비스를 복사하고 systemd가 인식할 수 있도록 systemctl daemon-reload를 실행합니다:

cd /home/git/gitlab
sudo mkdir -p /usr/local/lib/systemd/system
sudo cp lib/support/systemd/* /usr/local/lib/systemd/system/
sudo systemctl daemon-reload

GitLab에서 제공하는 유닛은 Redis와 PostgreSQL을 어디서 실행하는지에 대한 가정을 거의 하지 않습니다.

GitLab을 다른 디렉터리에 설치하거나 기본값 이외의 사용자로 설치한 경우, 유닛에서도 이 값들을 변경해야 합니다.

예를 들어, GitLab과 동일한 머신에서 Redis와 PostgreSQL을 실행하는 경우 다음을 수행해야 합니다:

Puma 서비스 편집:

sudo systemctl edit gitlab-puma.service

열리는 편집기에서 다음을 추가하고 파일을 저장합니다:

[Unit]
Wants=redis-server.service postgresql.service
After=redis-server.service postgresql.service

Sidekiq 서비스 편집:

sudo systemctl edit gitlab-sidekiq.service

다음을 추가하고 파일을 저장합니다:

[Unit]
Wants=redis-server.service postgresql.service
After=redis-server.service postgresql.service

systemctl edit/etc/systemd/system/<유닛 이름>.d/override.conf에 드롭인 구성 파일을 설치하므로, 나중에 유닛 파일을 업데이트할 때 로컬 구성을 덮어쓰지 않습니다. 드롭인 구성 파일을 분리하려면 /etc/systemd/system/<유닛 이름>.d/ 아래의 .conf 파일에 이전 스니펫을 추가할 수 있습니다.

(systemctl edit을 사용하지 않고) 유닛 파일을 수동으로 변경하거나 드롭인 구성 파일을 추가한 경우, 변경 사항이 적용되도록 다음 명령어를 실행합니다:

sudo systemctl daemon-reload

부팅 시 GitLab이 시작되도록 설정합니다:

sudo systemctl enable gitlab.target

SysV init 스크립트 설치#

SysV init 스크립트를 사용하는 경우 이 단계를 사용하세요. systemd를 사용하는 경우 systemd 유닛 단계를 따르세요.

init 스크립트를 다운로드합니다 (/etc/init.d/gitlab):

cd /home/git/gitlab
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab

기본값이 아닌 폴더나 사용자로 설치하는 경우 기본값 파일을 복사하고 편집합니다:

sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab

GitLab을 다른 디렉터리에 설치하거나 기본값 이외의 사용자로 설치한 경우, /etc/default/gitlab에서 이 설정을 변경해야 합니다. 업그레이드 시 변경되기 때문에 /etc/init.d/gitlab은 편집하지 마세요.

부팅 시 GitLab이 시작되도록 설정합니다:

sudo update-rc.d gitlab defaults 21
# or if running this on a machine running systemd
sudo systemctl daemon-reload
sudo systemctl enable gitlab.service

Logrotate 설정#

sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

Gitaly 시작#

다음 섹션을 위해 Gitaly가 실행 중이어야 합니다.

systemd를 사용하여 Gitaly를 시작하려면:

sudo systemctl start gitlab-gitaly.service

SysV용으로 Gitaly를 수동으로 시작하려면:

gitlab_path=/home/git/gitlab
gitaly_path=/home/git/gitaly

sudo -u git -H sh -c "$gitlab_path/bin/daemon_with_pidfile $gitlab_path/tmp/pids/gitaly.pid \
  $gitaly_path/_build/bin/gitaly $gitaly_path/config.toml >> $gitlab_path/log/gitaly.log 2>&1 &"

데이터베이스 초기화 및 고급 기능 활성화#

cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
# Type 'yes' to create the database tables.

# or you can skip the question by adding force=yes
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production force=yes

# When done, you see 'Administrator account created:'

환경 변수 GITLAB_ROOT_PASSWORDGITLAB_ROOT_EMAIL로 관리자/root 비밀번호와 이메일을 설정할 수 있습니다. 비밀번호를 설정하지 않으면 (기본값으로 설정된 경우) 설치가 완료되고 서버에 처음 로그인할 때까지 GitLab을 공개 인터넷에 노출하지 마세요. 첫 번째 로그인 시 기본 비밀번호를 변경하도록 강제됩니다. Enterprise Edition 구독은 GITLAB_ACTIVATION_CODE 환경 변수로 활성화 코드를 제공하여 이 시점에 활성화할 수 있습니다.

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword GITLAB_ROOT_EMAIL=youremail GITLAB_ACTIVATION_CODE=yourcode

secrets.yml 보안#

secrets.yml 파일은 세션 및 보안 변수의 암호화 키를 저장합니다. secrets.yml을 안전한 곳에 백업하되, 데이터베이스 백업과 같은 곳에 저장하지 마세요. 그렇지 않으면 백업 중 하나가 유출될 경우 시크릿이 노출됩니다.

애플리케이션 상태 확인#

GitLab과 환경이 올바르게 구성되었는지 확인합니다:

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

에셋 컴파일#

sudo -u git -H yarn install --production --pure-lockfile
sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production

rakeJavaScript heap out of memory 오류로 실패하면, 다음과 같이 NODE_OPTIONS를 설정하여 실행해 보세요.

sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production NODE_OPTIONS="--max_old_space_size=4096"

GitLab 인스턴스 시작#

# For systems running systemd
sudo systemctl start gitlab.target

# For systems running SysV init
sudo service gitlab start

10. NGINX#

NGINX는 GitLab에서 공식적으로 지원하는 웹 서버입니다. NGINX를 웹 서버로 사용할 수 없거나 사용하지 않으려면 GitLab 레시피를 참조하세요.

설치#

sudo apt-get install -y nginx

사이트 설정#

사이트 설정 예제를 복사합니다:

sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

설정에 맞게 구성 파일을 편집해야 합니다. 특히 git 사용자 이외의 사용자로 설치하는 경우 GitLab 경로가 일치하는지 확인하세요:

# Change YOUR_SERVER_FQDN to the fully-qualified
# domain name of your host serving GitLab.
#
# Remember to match your paths to GitLab, especially
# if installing for a user other than 'git'.
#
# If using Ubuntu default nginx install:
# either remove the default_server from the listen line
# or else sudo rm -f /etc/nginx/sites-enabled/default
sudo editor /etc/nginx/sites-available/gitlab

GitLab Pages를 활성화하려면 별도의 NGINX 설정이 필요합니다. 필요한 설정에 대한 자세한 내용은 GitLab Pages 관리 가이드를 참조하세요.

HTTPS를 사용하려면 gitlab NGINX 설정을 gitlab-ssl로 교체하세요. HTTPS 설정에 대한 자세한 내용은 HTTPS 사용하기를 참조하세요.

NGINX가 GitLab-Workhorse 소켓을 읽을 수 있도록 하려면, www-data 사용자가 GitLab 사용자가 소유한 소켓을 읽을 수 있어야 합니다. 이는 소켓이 world-readable인 경우, 예를 들어 기본값인 0755 권한을 가지고 있는 경우 달성됩니다. www-data도 상위 디렉터리 목록을 볼 수 있어야 합니다.

설정 테스트#

다음 명령어로 gitlab 또는 gitlab-ssl NGINX 설정 파일을 검증합니다:

sudo nginx -t

syntax is okaytest is successful 메시지를 받아야 합니다. 오류 메시지가 표시되면 제공된 오류 메시지에 표시된 대로 gitlab 또는 gitlab-ssl NGINX 구성 파일에서 오타를 확인하세요.

설치된 버전이 1.12.1보다 최신인지 확인합니다:

nginx -v

버전이 낮으면 다음과 같은 오류가 발생할 수 있습니다:

nginx: [emerg] unknown "start$temp=[filtered]$rest" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

재시작#

# For systems running systemd
sudo systemctl restart nginx.service

# For systems running SysV init
sudo service nginx restart

설치 후 작업#

애플리케이션 상태 재확인#

놓친 것이 없는지 더 철저한 확인을 실행합니다:

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

모든 항목이 녹색이라면, GitLab 설치를 성공적으로 완료한 것을 축하합니다!

확인 명령어 출력에서 프로젝트 이름을 생략하려면 `gitlab:check`에 `SANITIZE=true` 환경 변수를 제공하세요.

초기 로그인#

웹 브라우저에서 YOUR_SERVER를 방문하여 처음으로 GitLab에 로그인하세요.

설정 중 root 비밀번호를 제공하지 않은 경우, 초기 관리자 계정의 비밀번호를 설정하기 위한 비밀번호 재설정 화면으로 리디렉션됩니다. 원하는 비밀번호를 입력하면 로그인 화면으로 다시 리디렉션됩니다.

기본 계정의 사용자명은 root입니다. 이전에 생성한 비밀번호를 입력하여 로그인하세요. 로그인 후 원하면 사용자명을 변경할 수 있습니다.

즐기세요!

다음을 사용할 때 GitLab을 시작 및 중지하려면:

  • systemd 유닛: sudo systemctl start gitlab.target 또는 sudo systemctl stop gitlab.target을 사용합니다.

  • SysV init 스크립트: sudo service gitlab start 또는 sudo service gitlab stop을 사용합니다.

권장 다음 단계#

설치 완료 후, 인증 옵션과 신규 사용자 계정 제한 사항을 포함한 권장 다음 단계를 고려해보세요.

고급 설정 팁#

상대 URL 지원#

상대 URL로 GitLab을 설정하는 방법에 대한 자세한 내용은 상대 URL 문서를 참조하세요.

HTTPS 사용하기#

GitLab에 HTTPS를 사용하려면:

  • gitlab.yml에서:

섹션 1의 port 옵션을 443으로 설정합니다.

  • 섹션 1의 https 옵션을 true로 설정합니다.

  • GitLab Shell의 config.yml에서:

gitlab_url 옵션을 GitLab의 HTTPS 엔드포인트로 설정합니다 (예: https://git.example.com).

  • ca_file 또는 ca_path 옵션을 사용하여 인증서를 설정합니다.

  • gitlab 설정 대신 gitlab-ssl NGINX 예제 설정을 사용합니다.

YOUR_SERVER_FQDN을 업데이트합니다.

  • ssl_certificatessl_certificate_key를 업데이트합니다.

  • 구성 파일을 검토하고 다른 보안 및 성능 향상 기능 적용을 고려합니다.

자체 서명 인증서 사용은 권장되지 않습니다. 반드시 사용해야 한다면 표준 지침에 따라 자체 서명 SSL 인증서를 생성하세요:

mkdir -p /etc/nginx/ssl/
cd /etc/nginx/ssl/
sudo openssl req -newkey rsa:2048 -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key
sudo chmod o-r gitlab.key

이메일 답장 활성화#

설정 방법에 대한 자세한 내용은 "이메일 답장" 문서를 참조하세요.

LDAP 인증#

config/gitlab.yml에서 LDAP 인증을 설정할 수 있습니다. 이 파일을 편집한 후 GitLab을 재시작하세요.

커스텀 OmniAuth 공급자 사용하기#

OmniAuth 통합 문서를 참조하세요.

프로젝트 빌드#

GitLab은 프로젝트를 빌드할 수 있습니다. 이 기능을 활성화하려면 빌드를 수행할 runner가 필요합니다. 설치 방법은 GitLab Runner 섹션을 참조하세요.

신뢰할 수 있는 프록시 추가#

별도의 머신에서 리버스 프록시를 사용하는 경우 프록시를 신뢰할 수 있는 프록시 목록에 추가할 수 있습니다. 그렇지 않으면 사용자가 프록시의 IP 주소로 로그인한 것처럼 표시됩니다.

config/gitlab.yml의 섹션 1에 있는 trusted_proxies 옵션을 사용자 정의하여 신뢰할 수 있는 프록시를 추가할 수 있습니다. 파일을 저장하고 변경 사항이 적용되도록 GitLab을 재설정하세요.

URL에서 잘못 인코딩된 문자 문제가 발생하면 리버스 프록시 사용 시 404 Not Found 오류를 참조하세요.

커스텀 Redis 연결#

비표준 포트나 다른 호스트의 Redis 서버에 연결하려면 config/resque.yml 파일을 통해 연결 문자열을 설정할 수 있습니다.

# example
production:
  url: redis://redis.example.tld:6379

소켓을 통해 Redis 서버에 연결하려면 config/resque.yml 파일에서 unix: URL 스킴과 Redis 소켓 파일 경로를 사용하세요.

# example
production:
  url: unix:/path/to/redis/socket

또한 config/resque.yml 파일에서 환경 변수를 사용할 수 있습니다:

# example
production:
  url: <%= ENV.fetch('GITLAB_REDIS_URL') %>

커스텀 SSH 연결#

비표준 포트에서 SSH를 실행하는 경우 GitLab 사용자의 SSH 구성을 변경해야 합니다.

# Add to /home/git/.ssh/config
host localhost          # Give your setup a name (here: override localhost)
    user git            # Your remote git user
    port 2222           # Your port number
    hostname 127.0.0.1; # Your server name or IP

config/gitlab.yml 파일에서 해당 옵션(예: ssh_user, ssh_host, admin_uri)도 변경해야 합니다.

추가 마크업 스타일#

항상 지원되는 Markdown 스타일 외에도 GitLab에서 표시할 수 있는 다른 리치 텍스트 파일이 있습니다. 하지만 그렇게 하려면 의존성을 설치해야 할 수 있습니다. 자세한 내용은 github-markup gem README를 참조하세요.

Prometheus 서버 설정#

config/gitlab.yml에서 Prometheus 서버를 설정할 수 있습니다:

# example
prometheus:
  enabled: true
  server_address: '10.1.2.3:9090'

문제 해결#

메시지: 빈 리포지터리를 클론한 것 같습니다.#

GitLab이 호스팅하는 리포지터리를 클론하려고 할 때 이 메시지가 표시되면, 오래된 NGINX나 Apache 설정, 또는 누락되거나 잘못 설정된 GitLab Workhorse 인스턴스 때문일 가능성이 높습니다. Go 설치, GitLab Workhorse 설치, 그리고 NGINX 설정이 올바른지 다시 확인하세요.

google-protobuf 오류: LoadError: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.14' not found#

이 오류는 일부 플랫폼에서 google-protobuf 젬의 특정 버전에서 발생할 수 있습니다. 해결 방법은 이 젬의 소스 전용 버전을 설치하는 것입니다.

먼저, GitLab 설치에 필요한 google-protobuf의 정확한 버전을 찾아야 합니다:

cd /home/git/gitlab

# Only one of the following two commands will print something. It
# will look like: * google-protobuf (3.2.0)
bundle list | grep google-protobuf
bundle check | grep google-protobuf

다음 명령어에서 3.2.0은 예시로 사용되었습니다. 이전에 찾은 버전 번호로 교체하세요:

cd /home/git/gitlab
sudo -u git -H gem install google-protobuf --version 3.2.0 --platform ruby

마지막으로 google-protobuf가 올바르게 로드되는지 테스트할 수 있습니다. 다음은 OK를 출력해야 합니다.

sudo -u git -H bundle exec ruby -rgoogle/protobuf -e 'puts :OK'

gem install 명령어가 실패하면 OS의 개발자 도구를 설치해야 할 수 있습니다.

Debian/Ubuntu의 경우:

sudo apt-get install build-essential libgmp-dev

RedHat/CentOS의 경우:

sudo yum groupinstall 'Development Tools'

GitLab 에셋 컴파일 오류#

에셋을 컴파일하는 동안 다음과 같은 오류 메시지가 표시될 수 있습니다:

Killed
error Command failed with exit code 137.

이 오류는 메모리 부족 컨테이너를 Yarn이 종료할 때 발생할 수 있습니다. 이를 해결하려면:

시스템 메모리를 최소 8 GB 이상으로 늘리세요.

다음 명령어를 실행하여 에셋을 정리합니다:

sudo -u git -H bundle exec rake gitlab:assets:clean RAILS_ENV=production NODE_ENV=production

충돌을 해결하기 위해 yarn 명령어를 다시 실행합니다:

sudo -u git -H yarn install --production --pure-lockfile

에셋을 다시 컴파일합니다:

sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production