卸載本機gitliab以及相關文件
sudo gitlab-ctl uninstall
sudo rpm -e gitlab-ce
find / -name gitlab|xargs rm -rf
安裝相關依賴
yum install curl openssh-server openssh-clients postfix cronie policycoreutils-python –y
啓動postfix,並設置爲開機啓動
systemctl start postfix
systemctl enable postfix
防火牆設置
#此命令需在防火牆開啓後使用
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
獲取安裝包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.6.7-ce.0.el7.x86_64.rpm
安裝rpm包
rpm -ivh gitlab-ce-8.6.7-ce.0.el7.x86_64.rpm
修改配置文件gitlab.rb
vim /etc/gitlab/gitlab.rb
查找到
external_url 這個屬性,將其改爲ip+地址
加載配置文件並啓動
gitlab-ctl reconfigure
gitlab-ctl restart
訪問gitlab
更改密碼
首次進入會提示更改密碼,在界面直接操作即可,也可以使用命令行操作。
root命令下
[root@svr34 bin]# gitlab-rails console production
Loading production environment (Rails 4.2.5.2)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id: 1, email: "admin@example.com", ...
irb(main):002:0> user.password=12345678
=> 12345678
irb(main):003:0> user.password_confirmation=12345678
=> 12345678
irb(main):004:0> user.save!
=> true
irb(main):005:0> quit
即獲取用戶名和重置密碼。
gitlab創建一個項目
創建了一個jpa_test項目
導入客戶端公鑰
點擊項目上方的add an SSH key
超鏈,即可進入導入客戶端祕鑰界面
查找客戶端公鑰
mac祕鑰存在地址路徑爲 ~/.ssh
查看祕鑰
cat ~/.ssh/id_rsa.pub
將客戶端公鑰添加進gitlab
提交本地項目到gitlab
cd existing_folder
git init
git remote add origin git@47.104.225.224:root/jpa_test.git
git add .
git commit -m 'first commit'
git push -u origin master
查看具體文件報錯
現在clone和push都ok了,發現提交後的文件在線無法查看,頁面顯示500錯誤
查看gitlab日誌查看錯誤並修正
tail -f /var/log/gitlab/gitlab-rails/production.log
這是一臺阿里雲的新機器,內容爲2G,已經滿足gitlab最小內存1G的需求,通過free -h命令發現Swap爲0
於是根據網上資料通過增加swap來看看效果
修改後在線查看文件正常
至此gitlab搭建完美結束!