DevOps/Git

EPISODE 24. Ubuntu GitLab 설치

FEELFLOW 2023. 12. 5. 21:28

공식 가이드

https://about.gitlab.com/install/#ubuntu

 

Download and install GitLab

Download, install and maintain your own GitLab instance with various installation packages and downloads for Linux, Kubernetes, Docker, Google Cloud and more.

about.gitlab.com

 

1. 필수적인 의존성 라이브러리 설정 및 설치를 진행

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates

 

 

2. 메일 발송을 위한 Postfix를 설치 (필수 아님)

sudo apt-get install -y postfix

 

 

3. GitLab 패키지 저장소를 추가하고 패키지를 설치

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 
sudo EXTERNAL_URL="http://gitlab.example.com/" apt-get install gitlab-ce

 

 

4. GitLab ip:port 설정

sudo vi /etc/gitlab/gitlab.rb

 

external_url이라고 되어있는 부분 자신의 주소와 포트에 맞게 변경

 

 

5. 변경 후 적용

sudo gitlab-ctl reconfigure

 

 

6. GitLab root 계정 최조 비밀번호 설정 방법

sudo gitlab-rails console -e production
user = User.where(id: 1).first
=> #<User id:1 @root>
user.password='[변경할 비밀번호]'
user.password_confirmation='[변경할 비밀번호]'
user.save
=> true
exit

 

 

 

GitLab 삭제

1. 명령어

sudo gitlab-ctl cleanse
sudo gitlab-ctl uninstall
sudo apt-get remove gitlab-ce
sudo apt-get purge gitlab-ce

 

 

2. 해당 폴더 삭제

/opt/gitlab
/var/opt/gitlab
/etc/gitlab
/var/log/gitlab
/etc/yum.repos.d/gitlab 관련파일

 

 

디렉토리 삭제할 때는 -r 옵션

rm -r dir1

 

 

f 옵션을 추가하면 삭제할 건지 묻지 않고 바로 삭제

rm -rf dir1

 

 

 

GitLab 관련 명령어 정리

1. 설정 적용

gitlab-ctl reconfigure

 

 

2. 서비스 재시작

gitlab-ctl restart

 

 

3. 서비스 상태 확인

gitlab-ctl status

 

 

4. 서비스 중지

gitlab-ctl stop

 

gitlab 패스워드 위치

vi /etc/gitlab/initial_root_password

 

 

 

 

정상적으로 기동되었다.