温馨提示×

在CentOS上部署GitLab的步骤是什么

小樊
72
2025-03-29 16:21:20
栏目: 智能运维

在CentOS上部署GitLab的步骤如下:

一、安装前准备

  1. 更新系统
sudo yum update -y
  1. 安装依赖项
sudo yum install -y curl policycoreutils openssh-server openssh-clients postfix
  1. 启动并设置OpenSSH服务
sudo systemctl enable sshd
sudo systemctl start sshd
  1. 安装防火墙
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

二、添加GitLab仓库并安装GitLab

  1. 添加GitLab仓库
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  1. 安装GitLab
sudo yum install -y gitlab-ce

三、配置并启动GitLab

  1. 配置GitLab
  • 打开配置文件:
sudo vi /etc/gitlab/gitlab.rb
  • 修改外部URL(例如,设置为你的服务器IP或域名):
external_url 'http://your_server_ip'
  • 如果使用HTTPS,修改为:
external_url 'https://your_server_ip'
  • 保存并关闭配置文件。
  1. 配置并启动GitLab
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

四、访问GitLab

  • 在浏览器中访问配置的外部URL(例如:http://your_server_ip),首次访问时会引导你设置管理员账户和密码。

五、配置邮件服务(可选)

  • 如果需要配置邮件服务,可以参考GitLab官方文档进行设置。

六、配置防火墙(可选)

  • 如果需要开放其他端口(如SMTP邮件服务使用的端口),确保在防火墙中添加相应的规则。
sudo firewall-cmd --permanent --add-port=your_port/tcp
sudo firewall-cmd --reload

以上步骤是在CentOS 7上部署GitLab的基本流程。根据具体需求,可能还需要进行其他配置,如设置中文界面、配置备份等。

0