在CentOS7系統上安裝gitlab

最近公司的服務器壞了需要重新搭建gitlab,新買的服務器安裝的系統爲CentOS7,下面是本人安裝的過程記錄一下。

1.安裝ssh:

sudo yum install -y curl policycoreutils-pythonopenssh-server

第一步就報錯了:

CentOS報錯:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

百度發現是安裝系統時沒有配置DNS的問題,配置完DNS執行正常(配置DNS自行百度)

2.將SSH服務設置成開機自啓動,安裝命令:

sudo systemctl enable sshd 

3.啓動SSH服務,安裝命令:

sudo systemctl start sshd

4.安裝防火牆:

yum install firewalld systemd -y

5.開啓防火牆,安裝命令:

service firewalld start

6.添加http服務到firewalld,pemmanent表示永久生效,若不加--permanent系統下次啓動後就會失效。

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

7.重啓防火牆,安裝命令:

sudo systemctl reload firewalld

8.接下來,安裝Postfix以發送通知郵件,安裝命令:

sudo yum install postfix

9.將postfix服務設置成開機自啓動,安裝命令:

sudo systemctl enable postfix

10.啓動postfix,安裝命令:

sudo systemctl start postfix

11.wget 用於從外網上下載插件,安裝wget:

yum -y install wget

12.安裝vim編輯器 安裝命令:

yum install vim -y

前面12步是安裝gitlab的前提準備,接下來安裝gitlab,接下來會有不少坑

13.添加gitlab鏡像:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

14.安裝gitlab命令:

rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

如果發生下面錯誤:

warning: soft/gitlab-ce-10.7.3-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY

error: Failed dependencies:

        policycoreutils-python is needed by gitlab-ce-10.7.3-ce.0.el7.x86_64

根據提示安裝 policycoreutils-python

yum install policycoreutils-python

然後再執行安裝gitlab的命令:

rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm

安裝過程需要些時間,如果出現下圖,則說明安裝成功。

15.修改gitlab配置文件指定服務器ip和自定義端口:

vim /etc/gitlab/gitlab.rb

將external_url 'http://localhost'  ====》external_url 'http://ip:prot'

16.加載gitlab配置文件:

gitlab-ctl reconfigure

17.啓動gitlab:

gitlab-ctl restart

18.訪問 GitLab頁面,初始賬戶: root 密碼:5iveL!fe,但是登錄不進去,原因是沒有關閉防火牆

http://ip:port

19.關閉防火牆

暫時關閉防火牆

systemctl stop firewalld

永久關閉防火牆

systemctl disable firewalld

到這裏就可以訪問到gitlab頁面了。

 

GitLab 部署及管理員賬號初始化(參考:https://blog.csdn.net/hnmpf/article/details/80518460 )

獲取/修改超級管理員root的密碼

a、 切換目錄:cd /opt/gitlab/bin

b、執行 :sudo gitlab-rails console production 命令 開始初始化密碼

 

c、在irb(main):001:0> 後面通過 u=User.where(id:1).first 來查找與切換賬號(User.all 可以查看所有用戶)

 

d、通過u.password='12345678'設置密碼爲12345678(這裏的密碼看自己喜歡):

 

e、通過u.password_confirmation='12345678' 再次確認密碼

f、通過 u.save!進行保存(切記切記 後面的 !)

g、如果看到上面截圖中的true ,恭喜你已經成功了,執行 exit 退出當前設置流程即可。

h、回到gitlab ,可以通過 root/12345678 這一超級管理員賬號登錄了

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章