前言
GitLab:是一个基于Git实现的在线代码仓库托管软件,你可以用gitlab自己搭建一个类似于Github一样的系统,一般用于在企业、学校等内部网络搭建git私服。Gitlab 是一个提供代码托管、提交审核和问题跟踪的代码管理平台。对于软件工程质量管理非常重要。目前GitLab 分为社区版(CE) 和企业版(EE)。
本文将介绍一下CentOS环境下搭建GitLab服务器
一、GitLab安装
1、配置国内镜像源
新建并编辑如下目录文件
vim /etc/yum.repos.d/gitlab_gitlab-ce.repo
内容为:
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
重新生成yum缓存
yum makecache
2、安装并配置相关依赖
yum -y install curl openssh-server openssh-clients postfix cronie
service postfix start
chkconfig postfix on
3、安装
yum -y install gitlab-ce
二、Gitlab配置
1、编辑如下文件:
vim /etc/gitlab/gitlab.rb
配置外部访问地址
#外部访问url(经过编译后,自动将这个配置编译到nginx配置,nginx就无需配置了)
external_url 'http://gitlab.test.domain.com:8888'
#默认值就是8080。如果端口被占用,可将8080修改为其它(例如:9090)
unicorn['port'] = 8080
2、配置生效
#使配置生效
gitlab-ctl reconfigure
#重新启动GitLab
gitlab-ctl restart
三、GitLab常用命令
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
vim /etc/gitlab/gitlab.rb # 修改gitlab配置文件;
gitlab-ctl reconfigure # 重新编译gitlab的配置;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;
gitlab-ctl tail nginx/gitlab_access.log