阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7安装部署GitLab服务器

164次阅读
没有评论

共计 3001 个字符,预计需要花费 8 分钟才能阅读完成。

我这里使用的是 CentOS 7 64bit 安装部署 GitLab 服务器,我试过 CentOS 6 也是可以的。
1. 安装依赖软件
yum -y install policycoreutils openssh-server openssh-clients postfix
2. 设置 postfix 开机自启,并启动,postfix 支持 gitlab 发信功能
systemctl enable postfix && systemctl start postfix
3. 下载 gitlab 安装包,然后安装
centos 6 系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
centos 7 系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
我的是 centos7, 所以我在 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 中找了个 gitlab8.0.0 版本, 建议下载一个比较新的版本, 我这里选了一个比较旧的版本仅仅是实验
下载 rpm 包并安装:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
4. 修改 gitlab 配置文件指定服务器 ip 和自定义端口:
vim  /etc/gitlab/gitlab.rb
CentOS 7 安装部署 GitLab 服务器
退出并保存
ps: 注意这里设置的端口不能被占用,默认是 8080 端口,如果 8080 已经使用,请自定义其它端口,并在防火墙设置开放相对应得端口
5. 重置并启动 GitLab
执行:
gitlab-ctl reconfigure
gitlab-ctl restart
ok: run: gitlab-git-http-server: (pid 3922) 1s
ok: run: logrotate: (pid 3929) 0s
ok: run: nginx: (pid 3936) 1s
ok: run: postgresql: (pid 3941) 0s
ok: run: redis: (pid 3950) 0s
ok: run: sidekiq: (pid 3955) 0s
ok: run: unicorn: (pid 3961) 1s

提示“ok: run:”表示启动成功

6. 访问 GitLab 页面
如果没有域名,直接输入服务器 ip 和指定端口进行访问
初始账户: root 密码: 5iveL!fe
第一次登录修改密码
CentOS 7 安装部署 GitLab 服务器
6. 设置 gitlab 发信功能,需要注意一点:
发信系统用的默认的 postfix,smtp 是默认开启的,两个都启用了,两个都不会工作。
我这里设置关闭 smtp,开启 postfix
关闭 smtp 方法:vim /etc/gitlab/gitlab.rb
找到 #gitlab_rails[‘smtp_enable’] = true 改为 gitlab_rails[‘smtp_enable’] = false
修改后执行 gitlab-ctl reconfigure
另一种是关闭 postfix,设置开启 smtp,相关教程请参考官网 https://doc.gitlab.cc/omnibus/settings/smtp.html
测试是否可以邮件通知:
登录并添加一个用户,我这里使用 qq 邮箱添加一个用户
CentOS 7 安装部署 GitLab 服务器
登录 qq 邮箱,可以收到邮件通知(如果收不到,请查看垃圾邮箱或者检查邮件是否被拦截并删除,如果有请添加到白名单并删除用户再重新添加用户就可以收到了,否则请检查邮件日志并做好相关设置)
CentOS 7 安装部署 GitLab 服务器
报错处理:
一. 登录 502 报错
一般是权限问题,解决方法:chmod -R 755 /var/log/gitlab
如果还不行,请检查你的内存,安装使用 GitLab 需要至少 4GB 可用内存(RAM + Swap)! 由于操作系统和其他正在运行的应用也会使用内存, 所以安装 GitLab 前一定要注意当前服务器至少有 4GB 的可用内存. 少于 4GB 内存会出现各种诡异的问题, 而且在使用过程中也经常会出现 500 错误.
 
二.gitlab-ctl reconfigure
报错 n itdb: could not obtain information about current user: Permission denied
Error executing action `run` on resource ‘execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]’
根据报错信息大概锁定用户的权限问题, 安装 gitlab-ce 会自动添加用户四个用户:
gitlab-www:x:497:498::/var/opt/gitlab/nginx:/bin/false
git:x:496:497::/var/opt/gitlab:/bin/sh
gitlab-redis:x:495:496::/var/opt/gitlab/redis:/bin/nologin
gitlab-psql:x:494:495::/var/opt/gitlab/postgresql:/bin/sh
google 和百度都搜索不到解决方法, 既然出错提示到权限问题,那么按照这个方向去查就不会有问题,后来查了文件 /etc/passwd 的权限是 600, 给予 644 权限后, 成功解决报错问题。

更多 GitLab 相关教程见以下内容

Ubuntu 14.04 下安装 GitLab 指南  http://www.linuxidc.com/Linux/2015-12/126876.htm

如何在 Ubuntu Server 14.04 下安装 Gitlab 中文版  http://www.linuxidc.com/Linux/2015-12/126875.htm

CentOS 源码安装 GitLab 汉化版  http://www.linuxidc.com/Linux/2015-10/124648.htm

在 Ubuntu 12.04 上安装 GitLab http://www.linuxidc.com/Linux/2012-12/75249.htm

GitLab 5.3 升级注意事项 http://www.linuxidc.com/Linux/2013-06/86473.htm

在 CentOS 上部署 GitLab (自托管的 Git 项目仓库) http://www.linuxidc.com/Linux/2013-06/85754.htm

在 RHEL6/CentOS6/ScientificLinux6 上安装 GitLab 6.0.2 http://www.linuxidc.com/Linux/2014-03/97831.htm

CentOS 6.5 安装 GitLab 教程及相关问题解决 http://www.linuxidc.com/Linux/2014-05/101526.htm

升级 GitLab 到 8.2.0  http://www.linuxidc.com/Linux/2015-12/126220.htm

GitLab 的详细介绍:请点这里
GitLab 的下载地址:请点这里 

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-06/144990.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计3001字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中