在centos系統(tǒng)上部署gitlab,本文提供詳細(xì)步驟及問(wèn)題排查方法。
準(zhǔn)備工作
-
系統(tǒng)更新: 確保centos系統(tǒng)已更新到最新版本:
sudo yum update
-
依賴安裝: 安裝必要的軟件包:
-
SSH服務(wù)啟用: 設(shè)置SSH服務(wù)開(kāi)機(jī)自啟動(dòng):
sudo systemctl enable sshd sudo systemctl start sshd
-
防火墻配置: 允許http、https和SSH流量通過(guò)防火墻:
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload
-
gitLab YUM源添加: 添加gitlab官方Y(jié)UM源:
sudo curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
GitLab安裝與配置
-
GitLab安裝: 使用yum安裝GitLab社區(qū)版:
sudo yum install gitlab-ce
-
配置文件修改: 編輯/etc/gitlab/gitlab.rb文件,設(shè)置external_url為你的服務(wù)器IP地址和端口(例如http://your_server_ip:port)。 保存并退出。
-
GitLab重新配置和啟動(dòng):
sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
常見(jiàn)問(wèn)題解決
-
端口沖突: 如果出現(xiàn)端口占用錯(cuò)誤(Address already in use),使用以下命令查找并終止占用進(jìn)程:
lsof -i :port # 將port替換為沖突的端口號(hào) kill -9 pid # 將pid替換為進(jìn)程ID
-
防火墻問(wèn)題: 再次檢查防火墻設(shè)置,確保已開(kāi)啟HTTP (80), HTTPS (443) 和 SSH (22) 端口。
-
SELinux: 如果啟用SELinux,可能需要臨時(shí)禁用(注意安全風(fēng)險(xiǎn)):
sudo setenforce 0 sudo sed -i 's/SELinux=enforcing/SELINUX=disabled/g' /etc/selinux/config
安裝完成后,建議重新啟用SELinux。
完成以上步驟后,GitLab應(yīng)該已成功安裝并配置。 如有任何問(wèn)題,請(qǐng)參考GitLab官方文檔。