@@ -51,48 +51,38 @@ gitlab-postgresql:
51
51
- 本质就是把文件、缓存、数据库抽离出来,然后部署多个 Gitlab 用 nginx 前面做负载。
52
52
53
53
54
- # # 原始安装方式
54
+ # # 原始安装方式(推荐)
55
55
56
- - 环境:
57
- - CPU:1 core
58
- - 内存:2G
59
- - 我习惯使用 root 用户
56
+ - 推荐至少内存 4G,它有大量组件
60
57
- 有开源版本和收费版本,各版本比较:<https://about.gitlab.com/products/>
61
58
- 官网:<https://about.gitlab.com/>
62
59
- 中文网:<https://www.gitlab.com.cn/>
63
60
- 官网下载:<https://about.gitlab.com/downloads/>
64
- - 安装的系统环境要求:<https://docs.gitlab.com/ce/install/requirements.html>
65
- - 从文章看目前要求 ruby 2.3,用 yum 版本过低,那就源码安装 ruby 吧,官网当前最新是:2.4.1(大小:14M)
66
61
- 官网安装说明:<https://about.gitlab.com/installation/#centos-7>
67
- - 安装 ruby
68
- - 下载:<https://www.ruby-lang.org/en/downloads/>
69
- - 解压:`tar zxvf ruby-2.4.1.tar.gz`
70
- - 编译安装:
71
- - `cd ruby-2.4.1`
72
- - `./configure`
73
- - `make`,过程有点慢
74
- - `make install`
75
- - 默认安装到这个目录:`/usr/local`
76
- - 查看当前版本号:`ruby -v`
77
- - CentOS 6 安装流程:<https://about.gitlab.com/downloads/#centos6>
78
- - 当前(201703)的版本是:`GitLab Community Edition 9.0.0`
79
- - `sudo yum install -y curl openssh-server openssh-clients postfix cronie`
80
- - `sudo service postfix start`
81
- - `sudo chkconfig postfix on`
82
- - `sudo lokkit -s http -s ssh`
83
- - `curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash`
84
- - `sudo yum install gitlab-ce`,软件大小:272M,下载速度不稳定
85
- - `sudo gitlab-ctl reconfigure`,这个过程比较慢
86
62
- 如果上面的下载比较慢,也有国内的镜像:
87
63
- 清华:<https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/>
64
+ - 参考:<https://ken.io/note/centos7-gitlab-install-tutorial>
65
+
66
+ ` ` `
67
+ sudo yum install -y curl policycoreutils-python openssh-server
68
+
69
+ sudo systemctl enable sshd
70
+ sudo systemctl start sshd
71
+
72
+ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
73
+ sudo EXTERNAL_URL="http://192.168.1.123:8181" yum install -y gitlab-ce
74
+ ` ` `
88
75
89
76
90
77
# # 配置
91
78
92
79
- 配置域名 / IP
93
80
- 编辑配置文件:`sudo vim /etc/gitlab/gitlab.rb`
94
81
- 找到 13 行左右:`external_url 'http://gitlab.example.com'`,改为你的域名 / IP
95
- - 重启服务:`sudo gitlab-ctl reconfigure`
82
+ - 刷新配置:`sudo gitlab-ctl reconfigure`,第一次这个时间会比较久,我花了好几分钟
83
+ - 启动服务:`sudo gitlab-ctl start`
84
+ - 停止服务:`sudo gitlab-ctl stop`
85
+ - 重启服务:`sudo gitlab-ctl restart`
96
86
- 前面的初始化配置完成之后,访问当前机子 IP:`http://192.168.1.111:80`
97
87
- 默认用户是 `root`,并且没有密码,所以第一次访问是让你设置你的 root 密码,我设置为:gitlab123456(至少 8 位数)
98
88
- 设置会初始化密码之后,你就需要登录了。输入设置的密码。
@@ -234,6 +224,69 @@ gitlab-postgresql:
234
224
- <http://www.cnblogs.com/cnblogsfans/p/5075073.html>
235
225
236
226
227
+ # # 接入第三方登录
228
+
229
+ - 官网文档:
230
+ - <https://docs.gitlab.com/ce/integration/omniauth.html>
231
+ - <https://docs.gitlab.com/ce/integration/oauth2_generic.html>
232
+ - <https://gitlab.com/satorix/omniauth-oauth2-generic#gitlab-config-example>
233
+
234
+ - gitlab 自己本身维护一套用户系统,第三方认证服务一套用户系统,gitlab 可以将两者关联起来,然后用户可以选择其中一种方式进行登录而已。
235
+ - 所以,gitlab 第三方认证只能用于网页登录,clone 时仍然使用用户在 gitlab 的账户密码,推荐使用 ssh-key 来操作仓库,不再使用账户密码。
236
+ - 重要参数:block_auto_created_users=true 的时候则自动注册的账户是被锁定的,需要管理员账户手动的为这些账户解锁,可以改为 false
237
+ - 编辑配置文件引入第三方:`sudo vim /etc/gitlab/gitlab.rb`,在 309 行有默认的一些注释配置
238
+ - 其中 oauth2_generic 模块默认是没有,需要自己 gem,其他主流的那些都自带,配置即可使用。
239
+
240
+ ```
241
+ gitlab_rails[ 'omniauth_enabled'] = true
242
+ gitlab_rails[ 'omniauth_allow_single_sign_on'] = [ 'google_oauth2', 'facebook', 'twitter', 'oauth2_generic']
243
+ gitlab_rails[ 'omniauth_block_auto_created_users'] = false
244
+ gitlab_rails[ 'omniauth_sync_profile_attributes'] = [ 'email','username']
245
+ gitlab_rails[ 'omniauth_external_providers'] = [ 'google_oauth2', 'facebook', 'twitter', 'oauth2_generic']
246
+ gitlab_rails[ 'omniauth_providers'] = [
247
+ {
248
+ "name"=> "google_oauth2",
249
+ "label"=> "Google",
250
+ "app_id"=> "123456",
251
+ "app_secret"=> "123456",
252
+ "args"=> {
253
+ "access_type"=> 'offline',
254
+ "approval_prompt"=> '123456'
255
+ }
256
+ },
257
+ {
258
+ "name"=> "facebook",
259
+ "label"=> "facebook",
260
+ "app_id"=> "123456",
261
+ "app_secret"=> "123456"
262
+ },
263
+ {
264
+ "name"=> "twitter",
265
+ "label"=> "twitter",
266
+ "app_id"=> "123456",
267
+ "app_secret"=> "123456"
268
+ },
269
+ {
270
+ "name" => "oauth2_generic",
271
+ "app_id" => "123456",
272
+ "app_secret" => "123456",
273
+ "args" => {
274
+ client_options: {
275
+ "site" => "http://sso.cdk8s.com:9090/sso ",
276
+ "user_info_url" => "/oauth/userinfo"
277
+ },
278
+ user_response_structure: {
279
+ root_path: [ "user_attribute"] ,
280
+ attributes: {
281
+ "nickname": "username"
282
+ }
283
+ }
284
+ }
285
+ }
286
+ ]
287
+
288
+ ```
289
+
237
290
238
291
## 资料
239
292
0 commit comments