gitlab安裝教程


GitLab詳細安裝教程

GitLab是一個開源的用於倉庫管理的項目,使用Git作為代碼管理工具,大家應該都知道也使用過github這個網站吧,這兩個看起來非常的相似,他們有什么區別呢?
GitHub作為開源代碼庫,擁有超過 900 萬的開發者用戶,目前仍然是最火的開源項目托管平台,GitHub 同時提供公共倉庫和私有倉庫,但如果使用私有倉庫,是需要付費的。GitLab 解決了這個問題,你可以在上面創建私人的免費倉庫。
GitLab 讓開發團隊對他們的代碼倉庫擁有更多的控制,相比較 GitHub , 它有不少特色:
(1) 允許免費設置倉庫權限;
(2) 允許用戶選擇分享一個 project 的部分代碼;
(3) 允許用戶設置 project 的獲取權限,進一步提升安全性;
(4) 可以設置獲取到團隊整體的改進進度;
(5) 通過 innersourcing 讓不在權限范圍內的人訪問不到該資源;
所以,從代碼的私有性上來看,GitLab 是一個更好的選擇。但是對於開源項目而言,GitHub 依然是代碼托管的首選。

部署GitLab

環境配置

虛擬機 :VMware Workstation 15
主機名 :gitlab.example.com
IP地址 :192.168.0.102
系統版本 :CentOS Linux release 7.5.1804
內核版本:3.10.0-862.el7.x86_64
除此之外,還要在宿主機win10系統下的C:\Windows\System32\drivers\etc\hosts文件中添加如下內容
192.168.0.102 gitlab.example.com
官網硬件需求:

防止干擾實驗,關閉selinux和防火牆后重啟
[root@gitlab ~]# sed -i "s/enforcing/disabled/" /etc/selinux/config
[root@gitlab ~]# systemctl stop firewalld && systemmctl disable firewalld
[root@gitlab ~]# reboot
安裝postfix並設置開機自啟(新用戶激活郵件用到)
[root@gitlab ~]# yum install postfix
[root@gitlab ~]# systemctl start postfix && systemctl enable postfix
安裝gitlab組件
[root@gitlab ~]# yum install curl policycoreutils openssh-server openssh-clients
配置yum倉庫
[root@gitlab ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安裝社區版gitlab
[root@gitlab ~]# yum install -y gitlab-ce
也可以去https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm下載rpm包安裝

gitlab相關配置初始化並完成安裝

證書創建和加載配置

創建文件夾存放證書、key

[root@gitlab ~]# mkdir /etc/gitlab/ssl  

[root@gitlab ~]# cd /etc/gitlab/ssl/

創建私有密鑰 

[root@gitlab ssl]# openssl genrsa -out "/etc/gitlab/ssl/gitlab.example.com.key" 2048     //直接回車即可

 創建私有證書

[root@gitlab ssl]# openssl req -new -key "gitlab.example.com.key" -out "gitlab.example.com.csr"

用私有密鑰和私有證書創建CRT簽署證書

[root@gitlab ssl]# openssl x509 -req -days 365 -in "gitlab.example.com.csr" -signkey "gitlab.example.com.key" -out "gitlab.example.com.crt"

openssl命令生成pem證書,需要花點時間

[root@gitlab ssl]# openssl dhparam -out dhparams.pem 2048

查看前面生成的證書

修改證書文件權限

[root@gitlab ssl]# chmod 600 *

gitlab配置

備份gitlab配置文件

 [root@gitlab gitlab]# cp -a /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.bak

更改配置文件/etc/gitlab/gitlab.rb

vim /etc/gitlab/gitlab.rb

 

初始化gitlab相關服務配置

[root@gitlab ~]# gitlab-ctl reconfigure

nginx配置,備份配置文件

[root@gitlab ~]# cp -a /var/opt/gitlab/nginx/conf/gitlab-http.conf /var/opt/gitlab/nginx/conf/gitlab-http.conf.bak

[root@gitlab ~]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

 重啟gitlab

[root@gitlab ~]# gitlab-ctl restart

所有服務重啟成功

打開瀏覽器訪問gitlab.example.com,訪問gitlab的web頁面,安裝成功

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM