gitlab服务器搭建

gitlab本地部署


实验室需要一个代码管理,但是又不方便直接放到公网环境和github上,所以只能够自己在实验室内网搭建一个版本管理工具,免费的gitlab当然是个好的选择。

环境: Ubuntu 16.04LTS


gitlab安装

安装其实挺简单的,但是由于国内的环境,直接用gitlab官网源来安装gitlab可能会遇到下载不下来的问题,这里推荐清华的tuna镜像源,上面很多资源都有。
换源:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
  1. 安装依赖
sudo apt-get install curl openssh-server ca-certificates postfix
# 执行完成后,出现邮件配置,选择Internet那一项(不带Smarthost的)
  1. 首先信任 GitLab 的 GPG 公钥:
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
# 这里由于网络环境可能会失败多次,如果不行,可以换个时间段再试
  1. 安装gitlab-ce
sudo apt-get update
sudo apt-get install gitlab-ce
  1. 修改配置
    安装完成后需要进行一些配置修改
vim /etc/gitlab/gitlab.rb

找到external_url,修改为自己本子的ip地址或者域名,比如

external_url 'http://192.168.1.254'

修改之后重新生成配置并检查gitlab服务状态

gitlab-ctl reconfigure
sudo gitlab-ctl status

如果一切正常则可以使用Gitlab了

  1. 访问Gitlab
    输入IP访问Gitlab,注册账号进行愉快的搬砖之旅。

Gitlab默认使用SSH keys进行身份验证,正常使用需要配置相关密钥,具体步骤请参看Gitlab说明或者网上查询。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值