• Cập nhật hệ thống

[root@Gitlab ~]#dnf update -y

[root@Gitlab ~]#reboot

  • Thêm kho GitLab CE

[root@Gitlab ~]#curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

  • Cài đặt GitLab CE

[root@Gitlab ~]#dnf install -y gitlab-ce

#Thêm tên miền

[root@Gitlab ~]#nano /etc/gitlab/gitlab.rb

EXTERNAL_URL="http://tenmiencuaban"

#Apply các thay đổi

[root@Gitlab ~]#gitlab-ctl reconfigure

[root@Gitlab ~]#gitlab-ctl stop

[root@Gitlab ~]#gitlab-ctl start

  • Mở port firewall dịch vụ http or https

#Truy cập gitlab: 

http://tenmiencuaban hoặc http://ip>

#password ban đầu sẽ lưu ở đây 

[root@Gitlab ~]#cat /etc/gitlab/initial_root_passwordls

  • Cấu hình GitLab để kết nối LDAP/AD 

#Lưu ý: dns gitlab server cần phân giải được LDAP/AD server. Tạo user, OU trên  AD để xác thực kết nối

[root@Gitlab ~]#nano /etc/gitlab/gitlab.rb

#Thêm hoặc chỉnh sửa đoạn sau:

gitlab_rails['ldap_enabled'] = true

gitlab_rails['ldap_servers'] = {

'main' => {

   'label' => 'AD',

   'host' => ‘AD.GIANGIT.COM',

   'port' => 389,

   'uid' => 'sAMAccountName',

   'bind_dn' => ‘CN=gitlab,OU=IT,DC=giangit,DC=com',

   'password' => 'It12345678!',

'encryption' => 'plain',

   'verify_certificates' => true,

   'timeout' => 10,

   'active_directory' => true,

   'base' => ‘DC=giangit,DC=com',

   'user_filter' => '(objectClass=user)',

   'lowercase_usernames' => false

     }

}

#Save, exit, apply và kiểm tra cấu hình:

 [root@Gitlab ~]#gitlab-ctl reconfigure

[root@Gitlab ~]#gitlab-rake gitlab:ldap:check

#Truy cập để kiểm tra: 

http://tenmiencuaban hoặc http://ip>

 

------------------------------------------

Cài đặt SSL cho gitlab để sử dụng https://gitlab.giangit.com

  • Domain gitlab.yourdomain.com phải trỏ về IP server
  • Port 80 và 443 phải mở

[root@Gitlab ~]# nano /etc/gitlab/gitlab.rb

#Thêm nội dung

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

letsencrypt['enable'] = true

letsencrypt['contact_emails'] = ['email của bạn']

# Tự động renew

letsencrypt['auto_renew'] = true

[root@Gitlab ~]# gitlab-ctl reconfigure

GitLab sẽ:

  • Tự request SSL từ Let’s Encrypt
  • Tự cấu hình Nginx nội bộ

Truy cập: https://gitlab. giangit.com