在CentOS上配置GitLab涉及多个步骤,包括安装必要的依赖项、配置网络、设置邮件服务、安装GitLab以及修改配置文件等。以下是详细的配置步骤:
首先,更新系统并安装必要的依赖包:
sudo yum update -y
sudo yum install -y curl policycoreutils-python openssh-server postfix wget vim
配置防火墙,允许HTTP和HTTPS流量:
sudo yum install firewalld -y
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
安装并配置Postfix邮件服务器,用于发送GitLab通知邮件:
sudo yum install postfix -y
sudo systemctl enable postfix
sudo systemctl start postfix
在安装Postfix期间,可能会出现配置屏幕,选择“Internet Site”并按Enter键,使用您的服务器的外部DNS以“mail name”并按Enter,如果出现额外的屏幕,继续按Enter键接受默认值。
添加GitLab的RPM镜像源并安装GitLab软件包(版本号可能需要根据实际情况调整):
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-17.3.1-ce.0.el7.x86_64.rpm
sudo rpm -i gitlab-ce-17.3.1-ce.0.el7.x86_64.rpm
编辑GitLab配置文件 /etc/gitlab/gitlab.rb
,设置外部URL和其他必要配置:
sudo vim /etc/gitlab/gitlab.rb
例如,将外部URL设置为 http://your_server_ip:8080
。保存并关闭文件后,再次执行:
sudo gitlab-ctl reconfigure
启动GitLab服务并设置为开机自启动:
sudo gitlab-ctl start
sudo systemctl enable gitlab-ce
完成以上步骤后,您可以通过服务器IP地址和端口号(例如 http://your_server_ip:8080
)访问GitLab界面。首次登录使用用户名 root
和默认密码 5iveL!fe
,系统会提示您更改密码。
请注意,务必参考GitLab的官方文档获取最新的安装指南和配置说明,因为版本更新可能会导致步骤和配置项发生变化。