1. 程式人生 > >CentOS7下搭建Gitlib

CentOS7下搭建Gitlib

一、安裝配置依賴

1、安裝啟動ssh服務

sudo yum install -y curl policycoreutils-python openssh-server #安裝ssh
sudo systemctl enable sshd  #開機自啟
sudo systemctl start sshd   #啟動ssh

2、配置防火牆

sudo firewall-cmd --state #檢視防火牆狀態
sudo systemctl start firewalld #沒有啟動,可以啟動防火牆
sudo firewall-cmd --permanent --add-service=http #新增防火牆支援http永久訪問
sudo systemctl reload firewalld  #重新載入防火漆配置

3、安裝郵件服務

sudo yum install postfix -y   #安裝postfix
sudo systemctl enable postfix  #開機自啟
sudo systemctl start postfix  #啟動postfix

二、安裝配置gitlib

1. yum安裝

#下載此指令碼並執行,會自動下載當前系統的yum源,/etc/yum.repos.d/gitlab_gitlab-ee.repo
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

可以看到已經下載了yum源:gitlab_gitlab-ee.repo

[[email protected] software]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  gitlab_gitlab-ee.repo

新建源:vim /etc/yum.repos.d/gitlab-ce.repo,內容如下

[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

yum開始安裝

#重新整理yum快取
sudo yum makecache
#安裝
sudo yum install -y gitlab-ee

看到如下表示安裝成功

........
........
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

  Verifying  : gitlab-ce-11.4.0-ce.0.el7.x86_64                                                                                   1/1 

Installed:
  gitlab-ce.x86_64 0:11.4.0-ce.0.el7                                                                                                  

Complete!

2、配置訪問地址

#其他預設不變,如果需要用到的功能可以參考資料配置
external_url 'http://192.168.172.74:8081'

3、重新配置應用

gitlab-ctl reconfigure

4、啟動gitlab

gitlab-ctl status #檢視是否啟動
gitlab-ctl start  #沒有啟動可以啟動
gitlab-ctl restart #重新啟動
gitlab-ctl stop #停止

gitlab-ctl --help #檢視更多命令

5、防火牆開放埠

firewall-cmd --zone=public --list-ports #檢視開放埠
firewall-cmd --zone=public --add-port=8081/tcp --permanent #開放8081埠
firewall-cmd --reload   #重新載入配置
#如果不需要,也可以直接關閉防火牆
systemctl stop firewalld.service

三、登入

修改密碼後自動跳轉到登入頁面,用root和修改後密碼登入就可以

登入成功如下,就可以開始自己的操作了

參考