服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

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

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

2023-04-14 14:37多测师_郑sir Linux

这篇文章主要介绍了Linux 系统下搭建 Gitlab 服务器的过程,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

1、安装依赖工具

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

2、安装 Postfix 邮件服务器

?
1
2
3
4
5
// 安装 postfix
sudo yum install -y postfix
// 启动 postfix 并设置为开机启动
sudo systemctl enable postfix
sudo systemctl start postfix

3、安装防火墙

?
1
yum install firewalld systemd -y
?
1
2
3
4
5
// 开放 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
  • 镜像有点大,下载比较慢,根据网速快慢,需要等几分钟或者十几分钟
?
1
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm

5、安装 gitlab

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

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

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

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

?
1
2
3
4
5
6
7
// 输入编辑命令
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 服务器的过程分析

?
1
2
3
4
5
6
// 开放 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 了。
?
1
2
3
4
5
// 重置 gitlab
gitlab-ctl reconfigure
 
// 解决重置过程中卡住问题
systemctl restart gitlab-runsvdir

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

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

?
1
2
3
4
5
6
7
8
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 中查看
?
1
cat /etc/gitlab/initial_root_password

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

原文链接:https://zhengying0813.blog.csdn.net/article/details/124030956

延伸 · 阅读

精彩推荐