1. 程式人生 > 其它 >Gitlab環境搭建,git上傳程式碼到gitlab流程

Gitlab環境搭建,git上傳程式碼到gitlab流程

1.搭建虛擬機器環境

1.安裝一臺虛擬機器

1.搭建base

Vi /etc/hosts
192.168.233.140 cm04

2.克隆

 

2.設定機器名

設定機器名
hostnamectl set-hostname cm04

3.修改域名對映

vi /etc/hosts
192.168.233.129 cm01
192.168.233.130 cm02
192.168.233.131 cm03

 

4.固定IP地址

vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTROTO=”static”
IPADDR=”192.168.233.140”
NETMASK=”255.255.255.0”
GATEWAY=”192.168.233.2”
DNS1=”114.114.114.114”
DNS2=”8.8.8.8”
(附註:部分映象需加入ONBOOT="yes")

5.重啟網路

systemctl restart network

6.測試

ping www.baidu.com -c 3

7.關閉防火牆

systemctl stop firewalld
systemctl disable firewalld

8.更改安全機制

vi /etc/selinux/config
SELINUX=disabled

9.重啟

reboot

 

2.GitLab環境搭建

1. 安裝相關依賴

yum -y install policycoreutils openssh-server openssh-clients postfix

2. 啟動ssh服務&設定為開機啟動

systemctl enable sshd && sudo systemctl start sshd

3. 設定postfix開機自啟,並啟動,postfix支援gitlab發信功能

systemctl enable postfix && systemctl start postfix

4. 開放ssh以及http服務,然後重新載入防火牆列表

firewall-cmd --add-service=ssh --permanent

firewall-cmd --add-service=http --permanent

firewall-cmd --reload

如果關閉防火牆就不需要做以上配置

5. 下載gitlab包,並且安裝

上傳安裝包至root目錄,並解壓

(yum install policycoreutils-python)-->配置環境

rpm -ivh gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm

6. 修改gitlab配置

vi /etc/gitlab/gitlab.rb

修改gitlab訪問地址和埠,預設為80,我們改為82

external_url 'http://192.168.1.30:82'

nginx['listen_port'] = 82

7. 過載配置及啟動gitlab

gitlab-ctl reconfigure

gitlab-ctl restart

8. 把埠新增到防火牆

firewall-cmd --zone=public --add-port=82/tcp --permanent

firewall-cmd --reload
啟動成功後,看到以下修改管理員root密碼的頁面,修改密碼後,然後登入即可

9.瀏覽器訪問Gitlab,並重置ROOT使用者密碼

(訪問Gitlab的URL地址:http://192.168.233.140:82/)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(11)訪問Gitlab檢視程式碼是否提交成功