ubuntu搭建GitLab

目前Git是最流行的代码管理工具,git是分布式的,在多人协作,分支开发的项目上有其独特的优势。github上如果想建私有仓库是需要收取费用的,开源的GItLab允许我们搭建Git私有服务器。

下面介绍一下如何在自己的ubuntu服务器上搭建Gitlab。GitLab是一款开源的软件,在用基本的功能时时免费的,当需要提供额外的服务时需要收取费用。

下载最新版的gitlab,需要的机器配置:

ubuntu 14.0以上

服务器内存需要4G以上

gitlab运行比较消耗内存,4g一下服务器安装了也无法运行

安装gitlab可以去官方网站中查看教程,里面的教程也比较详细

https://about.gitlab.com/installation/#ubuntu

首先安装依赖包

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

下载gitlab

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 

sudo apt-get install gitlab-ce

由于gitlab是从国外服务器下载,需要翻墙,不然会非常慢,或者直接不成功

这个时候需要用到国内的镜像,https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

网站里有详细的设置说明,在里面选择相应的服务器操作系统和版本就行

这里需要注意:

在文档里将deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu xxxx main写入/etc/apt/sources.list.d/gitlab-ce.list文件中

在运行过程中如果不起作用,就替换成将内容写入/etc/apt/sources.list.d/gitlab_gitlab-ce.list中就可以。如果没有gitlab-ce.list或gitlab_gitlab-ce.list就手动建一个就可以。

最后在运行sudo apt-get install gitlab-ce就可以正常下载安装了

配置:

gitlab安装完成后就可以访问了

配置文件在:/etc/gitlab/gitlab.rb
如果无法正常启动服务,客户端访问报502等
可以修改端口号等一些信息,根据具体报错在网上有相应的配置方法予以解决
配置完成后运行
sudo gitlab-ctl reconfigure进行重新配置
 
常用命令:
sudo gitlab-ctl status 查看运行状态
gitlab-ctl restart 重启
gitlab-ctl tail 查看日志
gitlab-ctl reconfigure 重新装载配置
原文地址:https://www.cnblogs.com/leejay6567/p/9783192.html