GitLab的两种安装方法:

  • 编译安装

    • 优点:可定制性强。数据库既可以选择MySQL,也可以选择PostgreSQL;服务器既可以选择Apache,也可以选择Nginx。

    • 缺点:国外的源不稳定,被墙时,依赖软件包难以下载。配置流程繁琐、复杂,容易出现各种各样的问题。依赖关系多,不容易管理,卸载GitLab相对麻烦。

  • 通过rpm包安装

    • 优点:安装过程简单,安装速度快。采用rpm包安装方式,安装的软件包便于管理。

    • 缺点:数据库默认采用PostgreSQL,服务器默认采用Nginx,不容易定制


一.选择系统版本

       进入Gitlab官网选择自己服务器系统(此处我的版本是centos7)

         http://www.shcsinfo.com/china/gitdownload.html

   金庸武功之“漫天花雨”--gitlab 之 rpm安装方式_服务器



二.环境准备

  

sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

其中防火墙要是没装就不用执行

sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld


三.下载RPM包

这里由于网络影响因素,我们就不按照文档上说的步骤走了,在下面有个清华的yum源


For configuration and troubleshooting options please see the Omnibus GitLab documentation 
 If you are located in China, try using 
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/


直接进入https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/


CentOS/RHEL

新建 /etc/yum.repos.d/gitlab-ce.repo,内容为

你的CentOS/RHEL版本:   CentOS 6  CentOS 7  RHEL 6  RHEL 7 


[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

再执行

sudo yum makecache
sudo yum install gitlab-ce


这里需要注意的是,在时如果报错


大致就是yum源的问题,就把/etc/yum.repos.d/CentOS-Base.repo 改个名字

如:mv CentOS-Base.repo 00

这样再执行就OK了,


执行完

sudo yum makecache
sudo yum install gitlab-ce

再执行下

sudo gitlab-ctl reconfigure

就可以访问Gitlab了

http://192.168.92.2



开启gitlab的自动启动

systemctl enable gitlab-runsvdir.service
systemctl start gitlab-runsvdir.service
gitlab-cmd start



汉化:

需要下载汉化包,我们这里直接到去git一个。如果没安装git的请自行yum或apt-get 一个git。
比如我们现在到/usr/local/src,执行如下命令去git clone包:

      git clone https://gitlab.com/larryli/gitlab.git

其中如果在clone中报了如下的错:


[root@localhost /]# git clone https://gitlab.com/larryli/gitlab.git

正克隆到 'gitlab'...

remote: Counting objects: 261883, done.

remote: Compressing objects: 100% (54254/54254), done.

error: RPC failed; result=18, HTTP code = 20013.00 KiB/s    

fatal: The remote end hung up unexpectedly

fatal: 过早的文件结束符(EOF)

fatal: index-pack failed


是curl的postBuffer 默认值较小的原因,配置下个这个值,就不会出现该错误了.


在git目录下

git config --list

git config --global http.postBuffer 24288000

git config --list


再执行,就成功了


[root@localhost src]# git clone https://github.com/larryli/gitlabhq.git

正克隆到 'gitlabhq'...

remote: Counting objects: 261624, done.

remote: Compressing objects: 100% (23/23), done.

remote: Total 261624 (delta 1), reused 0 (delta 0), pack-reused 261601

接收对象中: 100% (261624/261624), 139.66 MiB | 34.00 KiB/s, done.

处理 delta 中: 100% (193704/193704), done.



新建新仓库目录

mkdir -p /mnt/application/gitlab/git-data


 修改配置文件 sudo vi /etc/gitlab/gitlab.rb 
 搜索:git_data_dir 修改成:git_data_dir "新目录" 
 如: git_data_dir "/mnt/application/gitlab/git-data"
 保存 
 重新生成gitlab sudo gitlab-ctl reconfigure