Linux 系统下搭建 Gitlab 服务器的过程分析

2023-12-07 0 282
目录
  • 1、安装依赖工具
  • 2、安装 Postfix 邮件服务器
  • 3、安装防火墙
  • 4、添加 gitlab 镜像源并安装 gitlab 服务器
  • 5、安装 gitlab
  • 6、安装后修改 gitlab 配置文件,指定访问服务器 ip 和自定义端口
  • 7、重置 Gitlab(让修改后的配置生效)
  • 8、启动 gitlab 并通过 ip + 端口访问
  • 9、登录 gitlab

1、安装依赖工具

// 安装技术依赖
yum install -y curl policycoreutils-python openssh-server
// 启动ssh服务/设置为开机启动
sudo systemctl enable sshd
sudo systemctl start sshd

2、安装 Postfix 邮件服务器

// 安装 postfix
sudo yum install -y postfix
// 启动 postfix 并设置为开机启动
sudo systemctl enable postfix
sudo systemctl start postfix

3、安装防火墙

yum install firewalld systemd -y
// 开放 ssh、http 服务
sudo firewall-cmd –add-service=ssh –permanent
sudo firewall-cmd –add-service=http –permanent
// 设置防火墙规则
sudo firewall-cmd –reload

4、添加 gitlab 镜像源并安装 gitlab 服务器

  • 镜像地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
  • 镜像有点大,下载比较慢,根据网速快慢,需要等几分钟或者十几分钟

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

5、安装 gitlab

安装过程需要些时间,安心等待,如果出现下图,则说明安装成功

rpm -ivh gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

Linux 系统下搭建 Gitlab 服务器的过程分析

6、安装后修改 gitlab 配置文件,指定访问服务器 ip 和自定义端口

// 输入编辑命令
vim /etc/gitlab/gitlab.rb

// 通过 vim 编辑命名找到 32 行
// 修改访问 URL
// 格式:external_url \’http://ip:端口\’
external_url \’http://119.29.xx.xxx:8081\’

Linux 系统下搭建 Gitlab 服务器的过程分析

  • 注意这里设置的端口不能被占用,默认是 8080 端口,如果 8080 已经使用,请自定义其它端口,像我这里就用了 8081 ,需要在防火墙设置开放相对应得端口
  • 配置完以后还需要修改一处,去掉 puma['port'] = 8080 前面的注释 #,并修改下端口号,注意和上面端口区分开,我这里用了 8082

Linux 系统下搭建 Gitlab 服务器的过程分析

// 开放 8081、8082 端口
firewall-cmd –permanent –zone=public –add-port=8081/tcp
firewall-cmd –permanent –zone=public –add-port=8082/tcp

// 重新加载防火墙配置
firewall-cmd –reload

7、重置 Gitlab(让修改后的配置生效)

  • 重置过程中如果出现在 action run 时卡住了情况,可以通过执行如下命令解决
    • 卡住问题解决后,需要重新重置下 gitlab
  • 重置过程可能需要几分钟,耐心等待就好!
  • 出现gitlab Reconfigured!,说明 OK 了。

// 重置 gitlab
gitlab-ctl reconfigure

// 解决重置过程中卡住问题
systemctl restart gitlab-runsvdir

Linux 系统下搭建 Gitlab 服务器的过程分析

8、启动 gitlab 并通过 ip + 端口访问

gitlab-ctl start // 启动所有 gitlab 组件;
gitlab-ctl stop // 停止所有 gitlab 组件;
gitlab-ctl restart // 重启所有 gitlab 组件;
gitlab-ctl status // 查看服务状态;
gitlab-ctl reconfigure // 刷新配置文件;
vim /etc/gitlab/gitlab.rb // 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true –trace // 检查gitlab;
gitlab-ctl tail // 查看日志;

Linux 系统下搭建 Gitlab 服务器的过程分析

9、登录 gitlab

  • 账号:root
  • 密码在文件/etc/gitlab/initial_root_password 中查看

cat /etc/gitlab/initial_root_password

到此这篇关于Linux 系统下搭建 Gitlab 服务器的文章就介绍到这了,更多相关Linux 搭建 Gitlab 服务器内容请搜索悠久资源以前的文章或继续浏览下面的相关文章希望大家以后多多支持悠久资源!

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 服务器其它 Linux 系统下搭建 Gitlab 服务器的过程分析 https://www.u-9.cn/server/qita-server/120389.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务