웹사이트 검색

Debian 11에 GitLab을 설치하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 데비안 11(Bullseye)
  • 데비안 8(Jessie)

이 페이지에서

  1. 전제 조건
  2. 시작하기\n
  3. GitLab 저장소 추가
  4. GitLab CE 설치
  5. GitLab 구성
  6. GitLab 액세스
  7. GitLab 백업 구성
  8. 결론

GitLab은 팀이 더 빠르게 반복하고 함께 혁신할 수 있는 무료 오픈 소스 DevOps 플랫폼입니다. GitLab Inc.에서 개발한 웹 기반 도구입니다. GitHub와 매우 유사하며 위키, 문제 추적, 지속적인 통합 및 배포를 제공하는 Git 리포지토리 관리자를 제공합니다. GitLab 커뮤니티 에디션은 개발 및 프로덕션 환경에서 완전 무료로 사용할 수 있습니다.

이 튜토리얼에서는 Nginx와 함께 GitLab을 설치하는 방법과 Debian 11에서 Lets Encrypt SSL을 사용하는 방법을 보여줍니다.

전제 조건

  • 최소 8GB RAM으로 Debian 11을 실행하는 서버.\n
  • 서버 IP로 가리키는 유효한 도메인 이름입니다.\n
  • 루트 암호는 서버에서 구성됩니다.\n

시작하기

시작하기 전에 패키지 캐시를 최신 버전으로 업데이트하는 것이 좋습니다. 다음 명령으로 수행할 수 있습니다.

apt-get update -y

완료되면 다음 명령을 사용하여 다른 필수 종속 항목을 설치합니다.

apt-get install curl ca-certificates apt-transport-https gnupg2 -y

필요한 종속성이 모두 설치되면 다음 단계로 진행할 수 있습니다.

GitLab 저장소 추가

기본적으로 GitLab 패키지는 Debian 기본 리포지토리에서 사용할 수 없습니다. 따라서 GitLab 저장소를 APT에 추가해야 합니다.

다음 스크립트를 실행하여 추가할 수 있습니다.

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash

이렇게 하면 APT 소스 목록 파일에 GitLab 리포지토리가 추가됩니다.

이 기사를 작성하는 시점에 GitLab 패키지는 Debian 11에서 사용할 수 없습니다. 따라서 GitLab 소스 파일을 편집하고 Debian 11 코드 이름을 Debian 10으로 바꿔야 합니다.

nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list

다음 줄을 찾으십시오.

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main

다음 줄로 교체했습니다.

deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main
deb-src https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main

파일을 저장하고 닫은 후 다음 명령을 사용하여 리포지토리를 업데이트합니다.

apt-get update -y

GitLab CE 설치

이제 다음 명령을 실행하여 GitLab CE를 설치할 수 있습니다.

apt-get install gitlab-ce -y

GitLab이 설치되면 다음과 같은 결과가 표시됩니다.

It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-3

GitLab 구성

이 시점에서 GitLab은 시스템에 설치되지만 아직 구성되지 않았습니다. 다음 파일을 편집하여 구성할 수 있습니다.

nano /etc/gitlab/gitlab.rb

도메인 이름으로 다음 줄을 변경합니다.

external_url 'https://gitlab.linuxbuz.com'

그런 다음 Lets Encrypt SSL을 활성화하도록 다음 줄을 변경합니다.

# Enable the Let's encrypt SSL
letsencrypt['enable'] = true

# This is optional to get SSL related alerts
letsencrypt['contact_emails'] = ['']

# This example renews every 7th day at 02:00 AM
letsencrypt['auto_renew_hour'] = "2"
letsencrypt['auto_renew_minute'] = "0"
letsencrypt['auto_renew_day_of_month'] = "*/7"

파일을 저장하고 닫은 후 다음 명령을 사용하여 GitLab을 다시 구성합니다.

gitlab-ctl reconfigure

GitLab이 재구성되면 GitLab 액세스 비밀번호가 포함된 다음 출력이 표시되어야 합니다.

Notes:
Default admin account has been configured with following details:
Username: root
Password: You didn't opt-in to print initial root password to STDOUT.
Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours.

NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

gitlab Reconfigured!

다음으로 다음 명령을 사용하여 GitLab 액세스 암호를 검색합니다.

cat /etc/gitlab/initial_root_password

다음 출력이 표시되어야 합니다.

# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: WBgnk2SH4xK5FeJVsJX0Qo79IeyE5LSTGWm3EjDVEkw=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.

GitLab에 액세스

이제 URL https://gitlab.linuxbuz.com을 사용하여 GitLab 대시보드에 액세스할 수 있습니다. GitLab 로그인 페이지로 리디렉션됩니다.

사용자 이름, 비밀번호를 입력하고 로그인 버튼을 클릭합니다. 다음 화면에 GitLab 대시보드가 표시되어야 합니다.

GitLab 백업 구성

설치 후 GitLab의 전체 백업을 수행하는 것이 좋습니다. 다음 명령으로 수행할 수 있습니다.

gitlab-rake gitlab:backup:create

/etc/crontab 파일을 편집하여 백업을 예약할 수도 있습니다.

nano /etc/crontab

다음 줄을 추가합니다.

0   22  *  *  *   root gitlab-rake gitlab:backup:create

완료되면 파일을 저장하고 닫습니다.

결론

축하합니다! Nginx와 함께 GitLab을 성공적으로 설치했고 데비안 11에 SSL을 허용합니다. 이제 개발 환경에서 GitLab을 구현하여 소프트웨어 개발 프로세스를 더 빠르게 만들 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.