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
- 安装依赖
sudo apt-get install curl openssh-server ca-certificates postfix
# 执行完成后,出现邮件配置,选择Internet那一项(不带Smarthost的)
- 首先信任 GitLab 的 GPG 公钥:
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
# 这里由于网络环境可能会失败多次,如果不行,可以换个时间段再试
- 安装gitlab-ce
sudo apt-get update
sudo apt-get install gitlab-ce
- 修改配置
安装完成后需要进行一些配置修改
vim /etc/gitlab/gitlab.rb
找到external_url,修改为自己本子的ip地址或者域名,比如
external_url 'http://192.168.1.254'
修改之后重新生成配置并检查gitlab服务状态
gitlab-ctl reconfigure
sudo gitlab-ctl status
如果一切正常则可以使用Gitlab了
- 访问Gitlab
输入IP访问Gitlab,注册账号进行愉快的搬砖之旅。
Gitlab默认使用SSH keys进行身份验证,正常使用需要配置相关密钥,具体步骤请参看Gitlab说明或者网上查询。