형상관리를 위한 협업 개발 도구 GitLab
사이트 정보
사이트 : https://gitlab.com
설 치 : https://about.gitlab.com/downloads
메뉴얼 : https://docs.gitlab.com/omnibus
1) Postfix 설치
<CentOS 6>
$ yum install curl openssh-server openssh-clients postfix cronie
$ service postfix start
$ chkconfig postfix on
$ lokkit -s http -s ssh
<CentOS 7>
$ yum install curl policycoreutils openssh-server openssh-clients
$ systemctl enable sshd
$ systemctl start sshd
$ yum install postfix
$ systemctl enable postfix
$ systemctl start postfix
$ firewall-cmd --permanent --add-service=http
$ systemctl reload firewalld
2) Postfix 구동시 오류 실패시 - 로그 확인 및 환경 파일 수정
$ tail -f /var/log/mailing
$ vi /etc/postfix/main.cf
inet_protocols = ipv4
3) GitLab 다운로드
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
Detected operating system as centos/6.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=centos&dist=6&source=script
done.
Installing pygpgme to verify GPG signatures...
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: ftp.neowiz.com
* epel: ftp.riken.jp
* extras: ftp.neowiz.com
* updates: ftp.neowiz.com
gitlab_gitlab-ce-source/signature | 836 B 00:00
Retrieving key from https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Importing GPG key 0xE15E78F4:
Userid: "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Retrieving key from https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
gitlab_gitlab-ce-source/signature | 951 B 00:00 ...
gitlab_gitlab-ce-source/primary | 175 B 00:00
Package pygpgme-0.1-18.20090824bzr68.el6.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: ftp.neowiz.com
* epel: ftp.riken.jp
* extras: ftp.neowiz.com
* updates: ftp.neowiz.com
Package yum-utils-1.1.30-40.el6.noarch already installed and latest version
Nothing to do
Generating yum cache for gitlab_gitlab-ce...
Importing GPG key 0xE15E78F4:
Userid: "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
The repository is setup! You can now install packages.
$
4) GitLab 설치
$ yum install gitlab-ce
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: ftp.neowiz.com
* epel: ftp.riken.jp
* extras: ftp.neowiz.com
* updates: ftp.neowiz.com
gitlab_gitlab-ce/signature | 836 B 00:00
gitlab_gitlab-ce/signature | 1.0 kB 00:00 ...
gitlab_gitlab-ce-source/signature | 836 B 00:00
gitlab_gitlab-ce-source/signature | 951 B 00:00 ...
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ce.x86_64 0:10.1.3-ce.0.el6 will be installed
--> Processing Dependency: policycoreutils-python for package: gitlab-ce-10.1.3-ce.0.el6.x86_64
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.0.83-30.1.el6_8 will be installed
--> Processing Dependency: libsemanage-python >= 2.0.43-4 for package: policycoreutils-python-2.0.83-30.1.el6_8.x86_64
--> Processing Dependency: audit-libs-python >= 1.4.2-1 for package: policycoreutils-python-2.0.83-30.1.el6_8.x86_64
--> Processing Dependency: setools-libs-python for package: policycoreutils-python-2.0.83-30.1.el6_8.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.0.83-30.1.el6_8.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.4.5-6.el6 will be installed
---> Package libcgroup.x86_64 0:0.40.rc1-24.el6_9 will be installed
---> Package libsemanage-python.x86_64 0:2.0.43-5.1.el6 will be installed
---> Package setools-libs-python.x86_64 0:3.3.7-4.el6 will be installed
--> Processing Dependency: setools-libs = 3.3.7-4.el6 for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libsefs.so.4(VERS_4.0)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libseaudit.so.4(VERS_4.2)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libseaudit.so.4(VERS_4.1)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.3)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libpoldiff.so.1(VERS_1.3)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libpoldiff.so.1(VERS_1.2)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.1)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libsefs.so.4()(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libseaudit.so.4()(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libpoldiff.so.1()(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: setools-libs-python-3.3.7-4.el6.x86_64
--> Running transaction check
---> Package setools-libs.x86_64 0:3.3.7-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
gitlab-ce x86_64 10.1.3-ce.0.el6 gitlab_gitlab-ce 349 M
Installing for dependencies:
audit-libs-python x86_64 2.4.5-6.el6 base 64 k
libcgroup x86_64 0.40.rc1-24.el6_9 updates 131 k
libsemanage-python x86_64 2.0.43-5.1.el6 base 81 k
policycoreutils-python x86_64 2.0.83-30.1.el6_8 base 437 k
setools-libs x86_64 3.3.7-4.el6 base 400 k
setools-libs-python x86_64 3.3.7-4.el6 base 222 k
Transaction Summary
====================================================================================================================================
Install 7 Package(s)
Total download size: 350 M
Installed size: 1.0 G
Is this ok [y/N]: y
Downloading Packages:
(1/7): audit-libs-python-2.4.5-6.el6.x86_64.rpm | 64 kB 00:00
(2/7): gitlab-ce-10.1.3-ce.0.el6.x86_64.rpm | 349 MB 00:32
(3/7): libcgroup-0.40.rc1-24.el6_9.x86_64.rpm | 131 kB 00:04
(4/7): libsemanage-python-2.0.43-5.1.el6.x86_64.rpm | 81 kB 00:00
(5/7): policycoreutils-python-2.0.83-30.1.el6_8.x86_64.rpm | 437 kB 00:06
(6/7): setools-libs-3.3.7-4.el6.x86_64.rpm | 400 kB 00:11
(7/7): setools-libs-python-3.3.7-4.el6.x86_64.rpm | 222 kB 00:03
------------------------------------------------------------------------------------------------------------------------------------
Total 5.5 MB/s | 350 MB 01:03
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Retrieving key from https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Importing GPG key 0xE15E78F4:
Userid: "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Is this ok [y/N]: y
Retrieving key from https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
Importing GPG key 0xF27EAB47:
Userid: "GitLab, Inc. <support@gitlab.com>"
From : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : audit-libs-python-2.4.5-6.el6.x86_64 1/7
Installing : libsemanage-python-2.0.43-5.1.el6.x86_64 2/7
Installing : libcgroup-0.40.rc1-24.el6_9.x86_64 3/7
Installing : setools-libs-3.3.7-4.el6.x86_64 4/7
Installing : setools-libs-python-3.3.7-4.el6.x86_64 5/7
Installing : policycoreutils-python-2.0.83-30.1.el6_8.x86_64 6/7
Installing : gitlab-ce-10.1.3-ce.0.el6.x86_64 7/7
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
Verifying : setools-libs-3.3.7-4.el6.x86_64 1/7
Verifying : gitlab-ce-10.1.3-ce.0.el6.x86_64 2/7
Verifying : libcgroup-0.40.rc1-24.el6_9.x86_64 3/7
Verifying : policycoreutils-python-2.0.83-30.1.el6_8.x86_64 4/7
Verifying : libsemanage-python-2.0.43-5.1.el6.x86_64 5/7
Verifying : setools-libs-python-3.3.7-4.el6.x86_64 6/7
Verifying : audit-libs-python-2.4.5-6.el6.x86_64 7/7
Installed:
gitlab-ce.x86_64 0:10.1.3-ce.0.el6
Dependency Installed:
audit-libs-python.x86_64 0:2.4.5-6.el6 libcgroup.x86_64 0:0.40.rc1-24.el6_9 libsemanage-python.x86_64 0:2.0.43-5.1.el6
policycoreutils-python.x86_64 0:2.0.83-30.1.el6_8 setools-libs.x86_64 0:3.3.7-4.el6 setools-libs-python.x86_64 0:3.3.7-4.el6
Complete!
5) 환경 파일 수정
$ vi /etc/gitlab/gitlab.rb
----------------------------------------
# 접속 호스트 설정
# https://localhost:8888
# http://localhost
# 위와 같이 프로토콜 호스트 포트 모두 한번에 설정한다.
external_url 'GENERATED_EXTERNAL_URL'
# SMTP Gmail 설정 (사용자 추가 및 비밀번호 변경시에 사용된다.)
# https://docs.gitlab.com/omnibus/settings/smtp.html#gmail
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.gmail.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "my.email@gmail.com"
gitlab_rails['smtp_password'] = "my-gmail-password"
gitlab_rails['smtp_domain'] = "smtp.gmail.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = falsegitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
# GitLab user 부분에 사용자 계정과 그룹명을 입력하는 곳이 있다.
# GitLab 에서 사용할 정보인데 만약 이미 있는 정보라면 수정해줘야 한다.
# user['username'] = "git"
# user['group'] = "git"
----------------------------------------
6) 변경된 환경파일을 저장하고 아래와 같이 설정을 반영한다.
$ sudo gitlab-ctl reconfigure
7) 프로토콜을 HTTPS로 사용시 SSL 인증서를 생성해야 한다.
[참고] https://docs.gitlab.com/omnibus/settings/nginx.html#enable-https
----------------------------------------
$ cd /etc/gitlab
// 개인키 생성하기
$ sudo openssl genrsa -des3 -out localhost.key 1024
// 임시 비밀번호 입력 메세지
Enter pass phrase for localhost.key:
Verifying - Enter pass phrase for localhost.key:
// CSR 파일 생성하기
$ sudo openssl req -new -days 365 -key localhost.key -out localhost.csr
Country Name = KR
State or Province Name = 지역 시
Locality Name = 지역 구
Organization Name = 회사명
Organizational Unit Name = 부서명
Common Name = 도메인
Email = 이메일
Challenge password = 무시
optional company name = 무시
// 백업
$ sudo cp localhost.key localhost.key.bak
$ sudo openssl rsa -in localhost.key.bak -out localhost.key
// SSL 인증서 생성
$ sudo openssl x509 -req -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt
// ssl 폴더 생성 및 인증서 복사
$ sudo mkdir -p /etc/gitlab/ssl
$ sudo chmod 700 /etc/gitlab/ss
$ sudo cp localhost.key localhost.crt /etc/gitlab/ssl
----------------------------------------
8) 서비스 시작과 종료 및 재설정
$ sudo gitlab-ctl start
$ sudo gitlab-ctl stop
$ sudo gitlab-ctl restart
$ sudo gitlab-ctl tail // 로그
https://localhost 사이트에 접속하면 관리자 암호를 설정하는 화면이 출력된다. 그리고 로그인 할때 관리자 계정은 root 이다.
9) 클라이언트에서 HTTPS 로 접근할 때 아래와 같은 오류가 발생하면 클라이언트에서 명령어를 실행해준다.
< ? > certificate problem: Invalid certificate chain
$ sudo git config --global http.sslVerify false
방화벽 때문에 접속이 안될 경우 포트나 프로토콜 등록해준다. 흔히 생기는 문제이니 잊지 말자
참고) http://syaku.tistory.com/326