|
1 |
| -# GitLab 安装和配置 |
| 1 | +# Gitlab 安装和配置 |
2 | 2 |
|
3 |
| -## GitLab 介绍 |
4 | 3 |
|
| 4 | +## 测试机子硬件最低建议 |
5 | 5 |
|
6 |
| -- 官网:<> |
7 |
| -- 官网下载:<https://www.gitlab.cc/downloads> |
8 |
| -- 官网安装说明:<https://doc.gitlab.cc/ce/install/requirements.html> |
9 |
| -- 开源版本和企业版本对比:<https://www.gitlab.cc/features/#enterprise> |
| 6 | +- CPU:1 core |
| 7 | +- 内存:2G |
10 | 8 |
|
11 |
| -## GitLab 安装(CentOS 6) |
| 9 | +## 安装 |
12 | 10 |
|
13 |
| -- 安装并开放 HTTP 和 SSH、邮件相关服务和端口 |
14 |
| - - 命令:`sudo yum install -y curl openssh-server openssh-clients postfix cronie` |
15 |
| - - 命令:`sudo service postfix start` |
16 |
| - - 命令:`sudo chkconfig postfix on` |
17 |
| - - 命令:`sudo lokkit -s http -s ssh` |
18 |
| -- 添加 GitLab 仓库,并安装到服务器上(8.8.4 安装包有:261M): |
19 |
| - - `curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash` |
20 |
| - - `sudo yum install -y gitlab-ce` |
21 |
| -- 启动 GitLab:`sudo gitlab-ctl reconfigure`,使用这个命令会输出一堆的日志出来,整个启动过程需要耗时 20 秒左右 |
| 11 | +- 我习惯使用 root 用户 |
| 12 | +- 有开源版本和收费版本,各版本比较:<https://about.gitlab.com/products/> |
| 13 | +- 官网:<https://about.gitlab.com/> |
| 14 | +- 中文网:<https://www.gitlab.com.cn/> |
| 15 | +- 官网下载:<https://about.gitlab.com/downloads/> |
| 16 | +- 安装的系统环境要求:<https://docs.gitlab.com/ce/install/requirements.html> |
| 17 | + - 从文章看目前要求 ruby 2.3,用 yum 版本过低,那就源码安装 ruby 吧,官网当前最新是:2.4.1(大小:14M) |
| 18 | +- 安装 ruby |
| 19 | + - 下载:<https://www.ruby-lang.org/en/downloads/> |
| 20 | + - 解压:`tar zxvf ruby-2.4.1.tar.gz` |
| 21 | + - 编译安装: |
| 22 | + - `cd ruby-2.4.1` |
| 23 | + - `./configure` |
| 24 | + - `make`,过程有点慢 |
| 25 | + - `make install` |
| 26 | + - 默认安装到这个目录:`/usr/local` |
| 27 | + - 查看当前版本号:`ruby -v` |
| 28 | +- CentOS 6 安装流程:<https://about.gitlab.com/downloads/#centos6> |
| 29 | + - 当前(201703)的版本是:`GitLab Community Edition 9.0.0` |
| 30 | + - `sudo yum install -y curl openssh-server openssh-clients postfix cronie` |
| 31 | + - `sudo service postfix start` |
| 32 | + - `sudo chkconfig postfix on` |
| 33 | + - `sudo lokkit -s http -s ssh` |
| 34 | + - `curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash` |
| 35 | + - `sudo yum install gitlab-ce`,软件大小:272M,下载速度不稳定 |
| 36 | + - `sudo gitlab-ctl reconfigure`,这个过程比较慢 |
| 37 | +- 如果上面的下载比较慢,也有国内的镜像: |
| 38 | + - 清华:<https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/> |
| 39 | + |
| 40 | + |
| 41 | +## 配置 |
| 42 | + |
| 43 | +- 配置域名 / IP |
| 44 | + - 编辑配置文件:`sudo vim /etc/gitlab/gitlab.rb` |
| 45 | + - 找到 13 行左右:`external_url 'http://gitlab.example.com'`,改为你的域名 / IP |
| 46 | + - 重启服务:`sudo gitlab-ctl reconfigure` |
| 47 | +- 前面的初始化配置完成之后,访问当前机子 IP:`http://192.168.1.111:80` |
| 48 | +- 默认用户是 root,并且没有密码,所以第一次访问是让你设置你的 root 密码,我设置为:gitlab123456(至少 8 位数) |
| 49 | +- 设置会初始化密码之后,你就需要登录了。输入设置的密码。 |
| 50 | +- root 管理员登录之后常用的设置地址(请求地址都是 RESTful 风格很好懂,也应该不会再变了。): |
| 51 | + - 用户管理:<http://192.168.1.111/admin/users> |
| 52 | + - 用户组管理:<http://192.168.1.111/admin/groups> |
| 53 | + - 项目管理:<http://192.168.1.111/admin/projects> |
| 54 | + - 添加 SSH Keys:<http://192.168.1.111/profile/keys> |
| 55 | + - 给新创建的用户设置密码:<http://192.168.1.111/admin/users/用户名/edit> |
| 56 | + - 新创建的用户,他首次登录会要求他强制修改密码的,这个设定很棒! |
| 57 | +- 普通用户登录之后常去的链接: |
| 58 | + - 配置 SSH Keys:<http://192.168.1.111/profile/keys> |
| 59 | + |
| 60 | + |
| 61 | +## 权限 |
| 62 | + |
| 63 | +- 官网帮助文档的权限说明:<http://192.168.1.111/help/user/permissions> |
| 64 | + |
| 65 | +### 用户组的权限 |
| 66 | + |
| 67 | +- 用户组有这几种权限的概念:`Guest、Reporter、Developer、Master、Owner` |
| 68 | +- 这个概念在设置用户组的时候会遇到,叫做:`Add user(s) to the group`,比如链接:<http://192.168.1.111/admin/groups/组名称> |
| 69 | + |
| 70 | +|行为|Guest|Reporter|Developer|Master|Owner| |
| 71 | +|---|---|--:|---|---|---| |
| 72 | +|浏览组|✓|✓|✓|✓|✓| |
| 73 | +|编辑组| | | | |✓| |
| 74 | +|创建项目| | | |✓|✓| |
| 75 | +|管理组成员| | | | |✓| |
| 76 | +|移除组| | | | |✓| |
| 77 | + |
| 78 | +### 项目组的权限 |
| 79 | + |
| 80 | +- 项目组也有这几种权限的概念:`Guest、Reporter、Developer、Master、Owner` |
| 81 | + - `Guest`:访客 |
| 82 | + - `Reporter`:报告者; 可以理解为测试员、产品经理等,一般负责提交issue等 |
| 83 | + - `Developer`:开发者; 负责开发 |
| 84 | + - `Master`:主人; 一般是组长,负责对Master分支进行维护 |
| 85 | + - `Owner`:拥有者; 一般是项目经理 |
| 86 | +- 这个概念在项目设置的时候会遇到,叫做:`Members`,比如我有一个组下的项目链接:<http://192.168.1.111/组名称/项目名称/settings/members> |
| 87 | + |
| 88 | +|行为|Guest|Reporter|Developer|Master|Owner| |
| 89 | +|---|---|--:|---|---|---| |
| 90 | +|创建issue|✓|✓|✓|✓|✓| |
| 91 | +|留言评论|✓|✓|✓|✓|✓| |
| 92 | +|更新代码| |✓|✓|✓|✓| |
| 93 | +|下载工程| |✓|✓|✓|✓| |
| 94 | +|创建代码片段| |✓|✓|✓|✓| |
| 95 | +|创建合并请求| | |✓|✓|✓| |
| 96 | +|创建新分支| | |✓|✓|✓| |
| 97 | +|提交代码到非保护分支| | |✓|✓|✓| |
| 98 | +|强制提交到非保护分支| | |✓|✓|✓| |
| 99 | +|移除非保护分支| | |✓|✓|✓| |
| 100 | +|添加tag| | |✓|✓|✓| |
| 101 | +|创建wiki| | |✓|✓|✓| |
| 102 | +|管理issue处理者| | |✓|✓|✓| |
| 103 | +|管理labels| | |✓|✓|✓| |
| 104 | +|创建里程碑| | | |✓|✓| |
| 105 | +|添加项目成员| | | |✓|✓| |
| 106 | +|提交保护分支| | | |✓|✓| |
| 107 | +|使能分支保护| | | |✓|✓| |
| 108 | +|修改/移除tag| | | |✓|✓| |
| 109 | +|编辑工程| | | |✓|✓| |
| 110 | +|添加deploy keys| | | |✓|✓| |
| 111 | +|配置hooks| | | |✓|✓| |
| 112 | +|切换visibility level| | | | |✓| |
| 113 | +|切换工程namespace| | | | |✓| |
| 114 | +|移除工程| | | | |✓| |
| 115 | +|强制提交保护分支| | | | |✓| |
| 116 | +|移除保护分支| | | | |✓| |
| 117 | + |
| 118 | +### 批量从一个项目中的成员转移到另外一个项目 |
| 119 | + |
| 120 | +- 项目的设置地址:<http://192.168.1.111/组名称/项目名称/settings/members> |
| 121 | + - 有一个 Import 按钮,跳转到:<http://192.168.1.111/组名称/项目名称/project_members/import> |
| 122 | + |
| 123 | +### 限定哪些分支可以提交、可以 merge |
| 124 | + |
| 125 | +- 也是在项目设置里面:<http://192.168.1.111/组名称/项目名称/settings/repository#> |
| 126 | +- 设置 CI (持续集成) 的 key 也是在这个地址上设置。 |
| 127 | + |
| 128 | +## 使用 Gitlab 的一个开发流程 |
| 129 | + |
| 130 | +- 这篇文章很好,不多说了:<https://zhangmengpl.gitbooks.io/gitlab-guide/content/whatisgitflow.html> |
22 | 131 |
|
23 |
| -## GitLab 配置 |
24 | 132 |
|
25 |
| -- 用浏览器访问服务器 IP,比如我的是:http://192.168.1.113,就可以直接看到 GitLab 配置初始化界面,让你先重置管理员密码,因为密码不能太简单,所以我改为:http://192.168.1.113,这样比较好记又复杂 |
26 |
| -- 重新访问:http://192.168.1.113,输入账号密码:root、http://192.168.1.113 |
27 |
| -- 访问管理员控制台,添加用户:http://192.168.1.113/admin/users |
28 | 133 |
|
29 | 134 |
|
30 | 135 | ## 资料
|
| 136 | + |
| 137 | +- <http://blog.smallmuou.xyz/git/2016/03/11/%E5%85%B3%E4%BA%8EGitlab%E8%8B%A5%E5%B9%B2%E6%9D%83%E9%99%90%E9%97%AE%E9%A2%98.html> |
| 138 | +- <https://zhangmengpl.gitbooks.io/gitlab-guide/content/whatisgitflow.html> |
| 139 | +- <https://blog.coderstory.cn/2017/02/01/gitlab/> |
| 140 | +- <https://xuanwo.org/2016/04/13/gitlab-install-intro/> |
0 commit comments