【安装gitlab】Ubuntu上安装gitlab

首先说明一下我的实验环境:Ubuntu 16.04.7 LTS在这里插入图片描述

一、git的安装

sudo apt-get install git

二、gitlab的搭建

1、安装Postfix发送通知电子邮件,邮件配置选择internet site

sudo apt-get install curl openssh-server ca-certificates postfix

2、首先信任 GitLab 的 GPG 公钥

curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null

3、编辑文件,添加镜像

sudo vi /etc/apt/sources.list.d/gitlab-ce.list

在文件中添加一行

deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xenial main

4、安装 gitlab-ce,这里强调一下安装的是gitlab-ce版本而不是ee,ee是收费的企业版,ce是社区版,免费。

sudo apt-get update
sudo apt-get install gitlab-ce

5、修改ip
【step1】

sudo vim /etc/gitlab/gitlab.rb

在这里插入图片描述
将 ‘http://gitlab.example.com’改成’http://your pc/server ip’
【step2】

sudo vi /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

在这里插入图片描述
把gitlab.example.com改成你的pc/服务器的ip
6、编辑完成后,再sudo gitlab-ctl reconfigure一下,使配置生效,这个过程有点漫长,中途千万不要按回车等操作。

sudo gitlab-ctl reconfigure

7.打开 sshd 和 postfix 服务【选做】

service sshd start
service postfix start

8.为了使 GitLab 社区版的 Web 界面可以通过网络进行访问,我们需要允许 80 端口通过防火墙,这个端口是 GitLab 社区版的默认端口。为此需要运行下面的命令
sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
9.检查GitLab是否安装好并且已经正确运行,输入下面的命令

sudo gitlab-ctl status

如果得到类似下面的结果,则说明GitLab运行正常

run: gitaly: (pid 15680) 185s; run: log: (pid 15328) 239s
run: gitlab-monitor: (pid 15696) 184s; run: log: (pid 15484) 231s
run: gitlab-workhorse: (pid 15667) 186s; run: log: (pid 15208) 249s
run: logrotate: (pid 15273) 245s; run: log: (pid 15272) 245s
run: nginx: (pid 15238) 247s; run: log: (pid 15237) 247s
run: node-exporter: (pid 15467) 233s; run: log: (pid 15466) 233s
run: postgres-exporter: (pid 15722) 181s; run: log: (pid 15571) 217s
run: postgresql: (pid 14943) 342s; run: log: (pid 14942) 342s
run: prometheus: (pid 15709) 182s; run: log: (pid 15521) 223s
run: redis: (pid 14880) 348s; run: log: (pid 14879) 348s
run: redis-exporter: (pid 15504) 224s; run: log: (pid 15503) 224s
run: sidekiq: (pid 15189) 255s; run: log: (pid 15188) 255s
run: unicorn: (pid 15151) 261s; run: log: (pid 15150) 261s

11.在浏览器地址栏中输入:http://ip,即可访问GitLab的Web页面,首次登录需要更改密码,管理员用户名为root
这里的“http://ip”就是第五步设置的ip,将其输入浏览器导航栏,回车之后就能访问,首次登录需要设置密码,用户名设置为root

【叨叨碎碎念】
如果在安装gitlab的时候sudo gitlab-ctl reconfigure之前忘记配置ip,在web浏览器访问项目的时候,复制得到的项目git地址是:http://gitlab.example.com/…类似的格式,如果sudo gitlab-ctl reconfigure之前修改了ip,则复制到的git地址就是http://ip/…形式,这里笔者还是建议配置ip地址,否则后期使用的时候有一些麻烦,比如:
1、复制项目git地址的时候,要手动修改gitlab.example.com为pc/server的ip
2、邀请members的时候邀请链接也要修改才能生效

那么问题就来了,之前忘记配置ip就进行reconfigure之后,如何修改ip?

还是进行第五步的操作,然后输入:
gitlab-ctl restart
即可使配置生效

gitlab-ctl常用命令介绍

命令说明
check-config检查在gitlab中是否有任何配置。在指定版本中删除的rb
deploy-page安装部署页面
diff-config将用户配置与包可用配置进行比较
remove-accounts删除所有用户和组
upgrade升级
service-list查看所有服务
once如果GitLab服务停止了就启动服务,如果已启动就不做任何操作
restart重启GitLab服务
start如果GitLab服务停止了就启动服务,如果已启动就重启服务
stop停止GitLab服务
status查看GitLab服务状态
reconfigure重新配置GitLab并启动
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值