一.下載安裝文件
root@gitlab:~# wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/9/gitlab-ce-17.4.0-ce.0.el9.x86_64.rpm
二.執行安裝腳本
2.1 先執行安裝前的命令
root@gitlab:~# apt install -y perl-interpreter
root@gitlab:~# apt install -y openssh-server
root@gitlab:~# apt install -y policycoreutils-python-utils
2.2 再執行安裝命令
root@gitlab:~# rpm -Uvh gitlab-ce-17.4.0-ce.0.el9.x86_64.rpm
如果執行出現這個問題
就換個一個命令執行,執行拉取最新的:
root@gitlab:/opt/gitlab# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
安裝gitlab-ce,這會要一些時間:
root@gitlab:/opt/gitlab# sudo apt-get install gitlab-ce
繼續執行上圖中的命令:
root@gitlab:/opt/gitlab# sudo gitlab-ctl reconfigure
然后檢查下各個服務的狀態,均為run代表沒有問題
root@gitlab:/opt/gitlab# sudo gitlab-ctl status
三.驗證
3.1 獲取密碼
使用用戶名root,以及從 /etc/gitlab/initial_root_password 文件中獲取的密碼進行登錄。
root@gitlab:/opt/gitlab# cat /etc/gitlab/initial_root_password
登錄成功:
四. 日常命令
sudo gitlab-rake gitlab:check # 驗證GitLab配置
sudo gitlab-rake 'gitlab:password:reset[root]' # 重置GitLab root密碼
sudo gitlab-ctl status # 查看GitLab狀態
sudo gitlab-ctl stop # 停止GitLab
sudo gitlab-ctl restart # 重新啟動GitLab
sudo gitlab-ctl start # 啟動GitLab服務
sudo systemctl list-units --type=service | grep gitlab # 確定GitLab服務的名稱
sudo systemctl status gitlab-runsvdir # 查看GitLab服務的狀態
sudo systemctl is-enabled gitlab-runsvdir # 檢查是否設置了開機禁用GitLab服務:應該返回disabled
sudo systemctl stop gitlab-runsvdir # 停止當前運行的GitLab服務
sudo systemctl disable gitlab-runsvdir # 禁用GitLab服務:在下次啟動時不會自動運行
五.卸載命令
sudo gitlab-ctl stop # Shutdown Gitlab
sudo gitlab-ctl uninstall # Remove Gitlab services
sudo gitlab-ctl cleanse # Clean any data generated by usage of the package
sudo gitlab-ctl remove-accounts # Remove any Gitlab accounts on your system
sudo dpkg -P gitlab-ce # sudo apt-get purge gitlab-ce # Remove the package
sudo rm -rf /opt/gitlab /etc/gitlab /var/opt/gitlab # Remove all Gitlab paths
sudo apt update
sudo apt-get autoremove
sudo apt-get clean