首页 > 技术文章 > Gitlab安装

blsnt 2019-01-17 10:24 原文

 1.1 安装GitLab CE

1.1.1 创建或编辑 /etc/yum.repos.d/gitlab-ce.repo ,填入以下内容:

[root@gitlab ~]# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

注:由于网络问题,国内用户,建议使用清华大学的镜像源进行安装:

1.1.2 安装

[root@gitlab ~]# yum makecache
[root@gitlab ~]# yum install gitlab-ce #可以指定版本安装如gitlab-ce-10.8.7,不指定则是最新版

1.1.3 配置并启动gitlab-ce

[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl status   #查看状态

1.1.4 登录gitlab

gitlab默认端口是80端口,访问方式:http://IP

第一次登录gitlab,需要为root用户修改密码,root用户也是gitlab的超级管理员

1.2 卸载gitlab

1.2.1 停止gitlab

$ gitlab-ctl stop  

1.2.2 卸载gitlab

$ yum remove gitlab-ce

1.2.3 杀进程

$ ps –ef|grep gitlab
#杀掉第一个守护进程(runsvdir -P /opt/gitlab/service log)

1.2.4 删除gitlab文件

$ find / -name *gitlab*|xargs rm -rf      删除所有包含gitlab的文件及目录
$ find / -name gitlab |xargs rm -rf         删除备份的配置文件

1.3 更改gitlab cloneexternal_url

在安装gitlab,新建项目之后,默认的clone链接为git@gitlab.example:test/test.githttp也是gitlab.example这种 这样每次clone时候都需要手动改下,改成ip或者域名才可以,可以按照如下方式更改external_url

更改/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml文件(centos7) hostport即可 

vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
# 1. GitLab app settings
# ==========================

## GitLab settings
gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    host: 10.119.116.160
    port: 8181
    https: false

注意:更改后cloneexternal_url后执行gitlab-ctl restart,重新进入gitlab就生效了

1.4 gitlab仓库存储位置的修改方法

1.4.1 创建数据目录

$ mkdir -p /data/gitlab

1.4.2 修改gitlab配置文件

vim /etc/gitlab/gitlab.rb
在git_data_dir下面添加一句git_data_dir "/data/gitlab"

1.4.3 停止当前gitlab,重新加载配置

$ gitlab-ctl stop
$ gitlab-ctl reconfigure
$ gitlab-ctl start

 

推荐阅读