- 安装和配置依赖软件
yum install -y curl policycoreutils-python openssh-server systemctl enable sshd systemctl start sshd
- 安装Gitlab-ce版本
我们使用云厂商的负载均衡器,所以这边没有配置https,如果需要配置https请查看HTTPS配置
# 添加仓库 curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash #安装Gitlab-ce EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce
- 配置LDAP
配置文件/etc/gitlab/gitlab.rb
gitlab_rails['ldap_enabled'] = true ###! **remember to close this block with 'EOS' below** gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' main: # 'main' is the GitLab 'provider ID' of this LDAP server label: 'LDAP' host: 'x.x.x.x' port: 389 uid: 'cn' bind_dn: 'cn=Manager,dc=example,dc=com' method: 'plain' # "tls" or "ssl" or "plain" password: '123456' active_directory: true allow_username_or_email_login: false lowercase_usernames: false block_auto_created_users: false base: 'ou=people,dc=example,dc=com' user_filter: '' EOS
uid
默认sAMAccountName 这边配置为cn 如果要使用中文登录时就使用默认配置 bind_dn
域服务器的管理员账号,根据实际情况修改 active_directory
似乎是针对连接是否是ad域控的标示,因为这部分是域服务器的配置,故为true allow_username_or_email_login
用户登录是否用户名和邮箱都可以,方便用户故配置true base
用户列表所在的目录,因为新增的用户都在People下(试验了用户放在User时gitlab检测不到用户,故新建了一个目录People,并将新建的用户移入了该目录下),故这么配置,根据实际情况修改
修改完以上配置后需要重置gitlab
参数:
gitlab-ctl reconfigure gitlab-ctl restart # 查看日志 gitlab-ctl log
- 配置邮箱
配置文件/etc/gitlab/gitlab.rb
,配置完成之后需要gitlab-ctl reconfigure
和gitlab-ctl restart
QQ exmail (腾讯企业邮箱)配置如下,更多邮箱配置示例
gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "xxxx@xx.com" gitlab_rails['smtp_password'] = "password" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'xxxx@xx.com' gitlab_rails['smtp_domain'] = "exmail.qq.com"
Gitlab使用
在安装好gitlab
之后第一次访问时会让初始化root用户密码,初始化完之后使用正常登录就可以进入gitlab
,再使用LDAP用户登录,登录时可能出现的异常
.Could not authenticate you from Ldapmain because "Invalid credentials".
出现这种异常一般都是gitlab.rb配置文件中的配置有问题,修改配置文件后reconfigure
再重启gitlab
就可以重置Gitlab的root用户密码
1.gitlab-rails console production
2.查询root用户信息u=User.where(id:1).first
3.重置root密码u.password = 'YOUR_PASSWORD' u.password_confirmation = 'YOUR_PASSWORD'
4.保存以上操作u.save!
文章来源: Gitlab安装及集成LDAP