配置 CentOS 8 防火墙
GitLab Web 应用程序默认在端口 80 和 443 上运行。
因此,我们允许 Linux 防火墙中的 http 和 https 服务。
[root@gitlab-ce-01 ~]# firewall-cmd --permanent --add-service={http,https} success [root@gitlab-ce-01 ~]# firewall-cmd --reload success
在本文中,我们将学习如何在 CentOS 8 操作系统上安装 GitLab CE(社区版)。
GitLab 是基于 Web 的软件,用于管理完整的 DevOps 生命周期。
GitLab 提供了一个 Git 存储库管理器,可提供 wiki、问题跟踪和持续集成/持续部署 (CI/CD) 管道功能。
GitLab 由 GitLab Inc 开发,有以下两个版本。
- GitLab CE-Community Edition:它是 GitLab 的开放核心版本,在 MIT 许可下可用。
- GitLab EE - 企业版:它是 GitLab 的商业版。与 GitLab EE 相比,GitLab EE 加载了许多高级功能,但我们需要获得专有许可才能解锁这些功能。虽然,我们可以在没有许可证的情况下使用 GitLab EE,但它只会允许我们使用 GitLab CE 中提供的那些功能。
GitLab 最初是用 Ruby 编写的,但后来有些部分用 Go 语言重写。
在 CentOS 8 上安装 GitLab CE
从那以后,我们已经在 CentOS 8 机器上成功安装了 GitLab yum 存储库。
现在,我们可以使用 dnf 命令轻松安装 GitLab CE。
[root@gitlab-ce-01 ~]# dnf install -y gitlab-ce
GitLab CE 安装成功。
在 CentOS 8 上配置 GitLab CE
GitLab 的配置文件位于 /etc/gitlab 目录中。
在文本编辑器中打开 gitlab.rb 配置文件。
[root@gitlab-ce-01 ~]# vi /etc/gitlab/gitlab.rb
找到并设置 external_url 指令,如下所示。
external_url 'http://gitlab-ce-01.onitroad.com'
使用以下命令调用 GitLab 配置过程。
这需要一段时间才能完成。
[root@gitlab-ce-01 ~]# gitlab-ctl reconfigure Starting Chef Client, version 14.14.29 resolving cookbooks for run list: ["gitlab"] Synchronizing Cookbooks: - gitlab (0.0.1) - redis (0.1.0) - mattermost (0.1.0) - gitaly (0.1.0) - praefect (0.1.0) - letsencrypt (0.1.0) - package (0.1.0) - postgresql (0.1.0) - consul (0.1.0) - registry (0.1.0) - monitoring (0.1.0) - runit (5.1.3) - nginx (0.1.0) - crond (0.1.0) - acme (4.1.1) Installing Cookbook Gems: Compiling Cookbooks... ... ... ... * runit_service[redis-exporter] action restart (up to date) Recipe: monitoring::prometheus * runit_service[prometheus] action restart (up to date) * execute[reload prometheus] action run - execute /opt/gitlab/bin/gitlab-ctl hup prometheus Recipe: monitoring::alertmanager * runit_service[alertmanager] action restart (up to date) Recipe: monitoring::postgres-exporter * runit_service[postgres-exporter] action restart (up to date) Recipe: monitoring::grafana * runit_service[grafana] action restart (up to date) Running handlers: Running handlers complete Chef Client finished, 562/1517 resources updated in 44 minutes 21 seconds gitlab Reconfigured!
在 CentOS 8 上安装 GitLab CE 必备组件
GitLab CE 需要一些其他的软件包。
因此,我们使用 dnf 命令安装它们。
[root@gitlab-ce-01 ~]# dnf install -y curl policycoreutils openssh-server
所有三个软件包都已安装在我们的 CentOS 8 服务器上。
GitLab CE 需要本地 SMTP 服务器来发送电子邮件通知。
因此,我们在 GitLab CE 服务器上安装 Postfix。
[root@gitlab-ce-01 ~]# dnf install -y postfix
启动并启用 Postfix 服务。
[root@gitlab-ce-01 ~]# systemctl enable --now postfix.service Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service -> /usr/lib/systemd/system/postfix.service.
在 CentOS 8 上安装 GitLab Yum 存储库
GitLab 文档提供了一个脚本来安装 GitLab yum 存储库。
我们在这里执行相同的命令。
[root@gitlab-ce-01 ~]# curl https://packages.gon-itroad.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
访问 GitLab CE Web 界面
GitLab CE 是基于 Web 的,因此,我们只需要一个受支持的 Web 浏览器即可访问该应用程序。
在浏览器中浏览 URL http://gitlab-ce-01.onitroad.com。
由于我们是第一次访问 GitLab Web 界面,因此 GitLab 应用程序要求我们设置一个强管理员密码。
默认的 GitLab 管理用户是 root 。
为 GitLab root 用户设置强密码。
现在,以 root 用户身份登录 GitLab 应用程序。
我们已经到达 GitLab 应用程序的主屏幕。
单击“配置 GitLab”。
我们已被重定向到 GitLab Web 界面的仪表板。
我们可以确认我们的 CentOS 8 服务器上已安装的 GitLab 组件的版本。