在CentOS上搭建GitLab服务器是一个相对复杂的过程,需要安装多个依赖项并进行配置。以下是一个详细的指南,帮助你在CentOS 7上安装和配置GitLab。
更新系统:
sudo yum -y update
安装必要的依赖包:
sudo yum install -y curl openssl-devel policycoreutils-python openssh-server perl git nodejs rsync cronie postfix
启用并启动SSH服务:
sudo systemctl enable sshd
sudo systemctl start sshd
配置防火墙:
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
添加GitLab的yum源:
sudo curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安装GitLab CE:
sudo yum install -y gitlab-ce
修改GitLab的外部URL:
编辑 /etc/gitlab/gitlab.rb
文件,设置你的服务器IP地址:
sudo vi /etc/gitlab/gitlab.rb
找到以下行并修改:
external_url 'http://your_server_ip'
重新配置并启动GitLab:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
现在,你可以通过浏览器访问GitLab:
http://your_server_ip
首次访问时,系统会要求你创建一个管理员账户。