在CentOS上配置GitLab涉及多個步驟,包括安裝必要的依賴包、添加GitLab的RPM鏡像源、安裝GitLab軟件包、修改配置文件以及重啟服務。以下是詳細的配置過程:
首先,更新系統并安裝一些必要的依賴包,如SSH、防火墻、Postfix和wget。
sudo yum update
sudo yum install -y curl policycoreutils-python openssh-server postfix wget
配置防火墻以允許HTTP和HTTPS流量。
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
添加GitLab的RPM鏡像源并安裝GitLab軟件包。這里以GitLab社區版為例,使用清華大學的鏡像源。
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
sudo rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
修改GitLab的配置文件以指定服務器IP和自定義端口。
sudo vim /etc/gitlab/gitlab.rb
在配置文件中找到external_url
并修改為GitLab服務器的訪問地址及端口號。例如:
external_url 'http://your_server_ip:port'
修改完畢后,保存并退出編輯器。
執行以下命令對GitLab進行配置更新并啟動服務。
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
完成上述步驟后,您可以通過指定的服務器IP地址和端口號訪問GitLab界面。初次登錄時,使用預設的初始賬戶名(root)和默認密碼(5iveL!fe),首次登錄后系統會要求您更改密碼。
請注意,為了系統的安全性和穩定性,建議定期更新GitLab至最新版本,并根據實際需求進一步配置相關服務。