Centos8 中安装GitLab
1,安装依赖
1 | yum install -y curl policycoreutils-python openssh-server |
centos8没有policycoreutils-python yum源,不用管
2,启动ssh并设置为开机自启动
1 2 3 | systemctl enable sshd systemctl start sshd |
3,添加http服务到firewalld,pemmanent表示永久生效,若不加--permanent系统下次启动后就会失效
1 2 3 | systemctl start firewalld firewall-cmd --permanent --add-service=httpfirewall-cmd --permanent --add-service=httpssystemctl reload firewalld |
4,启动postfix
1 2 3 | systemctl enable postfix systemctl start postfix |
5,下载gitlab
1 | 去这个路径下找最新的: https: //mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8 ; 下面的命令对应也跟着修改 |
1 | wget https: //mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm |
6,安装
1 | rpm -i gitlab-ce- 12.10 . 1 -ce. 0 .el8.x86_64.rpm |
成功如图:
7,编辑ip和端口
1 2 3 4 5 | vim /etc/gitlab/gitlab.rb gitlab-ctl reconfigure gitlab-ctl restart |
8,访问gitlab ip+端口
如果输入端口和ip一直无法响应,可以关闭防火墙
systemctl stop firewalld
如果访问502,查看
https://www.cnblogs.com/fuhua/p/15414744.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 14 .之后在本机浏览器输入地址 http: //ip+端口 提示502错误! 15 .gitlab官方文档中说的是当CPU到达 100 %时会返回 502 错误,这个错误来自包Unicorn。 由于我们安装的gitlab是 14.3 . 3 版本,Unicorn包已被弃用,改名为Puma,所以我们可以初步判断是Puma包导致的 502 报错。 参考链接: 502 Gateway Timeout after Unicorn spins at 100 % CPU 16 .输入命令top查看cpu占用状态,发现command为bundle这个操作占用了 99.3 %的cpu,这明显是不合理的。 17 .实时打印 puma包的日志,发现输出 "Errno::EADDRINUSE: Address already in use - bind(2) for " 127.0 . 0.1 " port 8080" 。原因就很清晰了,是因为 8080 端口被占用。 #实时打印puma包的日志 sudo gitlab-ctl tail puma 15 .查看占用端口为 8080 并且状态为LISTEN的进程 发现 8080 端口被进程Id: 58799 进程名:nginx:maser 的进程占用了,这是gitlab自带的nginx默认的监听端口。 而包puma也需要监听 8080 端口,产生了冲突导致puma 执行build失败。 puma包在执行build失败之后会无限重试,导致了死循环把cpu跑到了 100 %。 netstat -anp |grep 8080 16 .接下来只需要给puma包设置默认监听端口不是 8080 就好了,我这里设置为 8081 vim /etc/gitlab/gitlab.rb 新增 puma[ 'port' ] = 8081 17 .依次执行下面命令 复制代码 #停止gitlab gitlab-ctl stop #重新加载gitlab配置 gitlab-ctl reconfigure #重新运行gitlab gitlab-ctl restart #监视cpu状态 top 复制代码 18 .可以看到两个CPU占用非常高的进程,此时如果您在本机访问搭建的gitlab地址,依旧会提示 502 。 因为此时gitlab正在构建,我们什么都不需要做。只需要等到这两个CPU占用很高的进程CPU降低后就可以访问了。 注:如果远程访问不是提示 502 错误,而是提示连接失败之类的。 80 %都是因为服务器防火墙限制或者云服务器提供商防火墙限制。 #停止服务器防火墙 sudo systemctl stop firewalld |
重新配置并启动
gitlab-ctl reconfigure
gitlab-ctl restart
开启:
gitlab-ctl start
关闭:
gitlab-ctl stop
9,成功如图:
10,第一次登录需要修改root密码, 密码8位以上,修改完就可以登录
使用设置的新密码,登录
其他操作类似添加账号,仓库等等自己百度
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具