Linux系统下怎么搭建Gitlab服务器

本篇内容主要讲解“Linux系统下怎么搭建Gitlab服务器”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux系统下怎么搭建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服务器  linux 第1张

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服务器  linux 第2张

  • 注意这里设置的端口不能被占用,默认是 8080 端口,如果 8080 已经使用,请自定义其它端口,像我这里就用了 8081 ,需要在防火墙设置开放相对应得端口

  • 配置完以后还需要修改一处,去掉 puma['port'] = 8080 前面的注释 #,并修改下端口号,注意和上面端口区分开,我这里用了 8082

Linux系统下怎么搭建Gitlab服务器  linux 第3张

// 开放 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服务器  linux 第4张

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服务器  linux 第5张

9、登录 gitlab

  • 账号:root

  • 密码在文件 /etc/gitlab/initial_root_password 中查看

cat /etc/gitlab/initial_root_password

到此,相信大家对“Linux系统下怎么搭建Gitlab服务器”有了更深的了解,不妨来实际操作一番吧!这里是蜗牛博客网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接