gitlab12.9.1安装和使用

童鞋们好啊!好久没见了。最近很多公司要用到git。今天我们聊一下gitlab。
也是现学现卖了,整理一下。方便以后使用和学习。

我这里使用的是centos 7 64bit, 在vm上哦!一般4G内存,否则会出现各种错误。常见的是502错误。

1. 安装依赖软件

yum -y install policycoreutils openssh-server openssh-clients postfix

2.设置postfix开机自启,并启动,postfix支持gitlab发信功能

systemctl enable postfix && systemctl start postfix

3.安装gitlab-ce

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
[root@localhost /]# yum install -y gitlab-ce

注:由于网络问题,国内用户,建议使用清华大学的镜像源进行安装:

[root@localhost /]# vim /etc/yum.repos.d/gitlab-ce.repo

#在编辑器中输入如下内容保存
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
#建立本地缓存 安装gitlat
[root@localhost /]# yum makecache
[root@localhost /]# yum install gitlab-ce

4. 配置并启动GitLab

[root@localhost /]# gitlab-ctl reconfigure
[root@localhost /]# 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:”表示启动成功

5.访问 GitLab页面

查看版本号
[root@localhost /]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.9.1

注:如果没有域名,直接输入服务器ip和指定端口进行访问 。gitlab版本号不同默认端口号也是不同的。老一些的版本是8080。 这个是默认80。如果开启防火墙。添加规则,开放端口即可。如果想该端口号

修改gitlab配置文件指定服务器ip和自定义端口

[root@localhost /]#   vi  /etc/gitlab/gitlab.rb
  

external_url ‘http://localhost:8083’

在这里插入图片描述
修改完之后重新配置一下就好

[root@localhost /]# gitlab-ctl reconfigure

第一次登录修改密码

在这里插入图片描述
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邮箱添加一个用户


在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

报错处理:

一.登录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]’

google和百度都搜索不到解决方法,既然出错提示到权限问题,那么按照这个方向去查就不会有问题,后来查了文件/etc/passwd的权限是600,给予644权限后,成功解决报错问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值