centos7.5安装gitlab10.1.6包括邮件及ldap设置

 安装并配置必要的依赖关系

CentOS 系统上,下面的命令将会打开系统防火墙 HTTP SSH 的访问。

lokkit -s http -s ssh 这个我没用

yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python

设置postfix开机自启,并启动,postfix支持gitlab发信功能

service postfix start

chkconfig postfix on

Centos7: systemctl enable postfix && systemctl start postfix

2. 添加 GitLab 镜像源并安装

centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6

centos 7系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7

我的是centos7,所以我在https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7中找了个gitlab****版本,建议下载一个比较新的版本,我这里选了一个比较旧的版本仅仅是实验

扫描二维码关注公众号,回复: 1347783 查看本文章

下载rpm包并安装:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.1.6-ce.0.el7.x86_64.rpm

rpm -i gitlab-ce-10.1.6-ce.0.el7.x86_64.rpm

3. 配置并启动 GitLab

gitlab-ctl reconfigure

1,按照该方式,我安装了一个确实没问题,只不过是英文版。没有经过汉化(汉化请参考后边的教程)。

2,默认安装登录需要重置root密码。可以自己单独设置一个复杂密码后登录。

3gitlab本身采用80端口,如安装前服务器有启用80,安装完访问会报错。需更改gitlab的默认端口。

修改vi /etc/gitlab/gitlab.rb  这里的配置文件格式要按照原来的,一个空格都不能多

external_url 'http://localhost:10086' 

如果就想用80端口,那没问题。如果更改了端口,后边可以自行调整nginx配置文件进行nginx反向代理设置。

unicorn端口默认是8080,如被占用需要更改不然会报错502,那就需要修改里面的端口,配置文件:/var/opt/gitlab/gitlab-rails/etc/unicorn.rb

提示:内存至少4G,不然也会出现502,一般服务器内存都会超过4G这个到不用担心

注意开放端口或关闭防火墙及selinux

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION  查看gitlab版本

gitlab-ctl start|stop|restart 重启后立马打开页面会出现502是因为unicorn启动较慢,可以等下再打开

gitlab邮件发送配置:

修改vi /etc/gitlab/gitlab.rb,在其中添加以下内容(里面本身有相应内容可以取消注释进行相应修改)

gitlab_rails['gitlab_email_enabled'] = true

gitlab_rails['gitlab_email_from'] = '***@xx.cn'

gitlab_rails['gitlab_email_reply_to'] = '***@xx.cn'

gitlab_rails['smtp_enable'] = true

gitlab_rails['smtp_address'] = "smtp.xx.cn"

gitlab_rails['smtp_port'] = 25

gitlab_rails['smtp_user_name'] = "***@xx.cn"

gitlab_rails['smtp_password'] = "******"

gitlab_rails['smtp_domain'] = "xx.cn"

gitlab_rails['smtp_authentication'] = "login"

gitlab_rails['smtp_enable_starttls_auto'] = false

gitlab_rails['smtp_tls'] = false

修改完成后执行:gitlab-ctl reconfigure

当然这样配置后就成功了但是添加新用户发送邮件里的密码设置链接域名会有误,这里我们要再修改下其中的配置:

external_url 'http://gitlab.example.com'

改为:external_url 'http://服务器ip或是域名'

Gitlab配置ldap用户认证:

GitLab集成LDAP认证

1、修改GitLab配置文件/etc/gitlab/gitlab.rb找到gitlab_rails['ldap_enabled']位置做如下配置:

gitlab_rails['ldap_enabled'] = true

gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'

    main: # 'main' is the GitLab 'provider ID' of this LDAP server

      label: 'LDAP'

      host: '10.1.*.*'

      port: 389

      uid: 'sAMAccountName'

      bind_dn: 'cn=administrator,cn=users,dc=guoge,dc=com'

      password: '*******'

      encryption: 'plain' # "start_tls" or "simple_tls" or "plain"

      timeout: 10

      verify_certificates: true

      ca_file: ''

      ssl_version: ''

      active_directory: true

      allow_username_or_email_login: false

      block_auto_created_users: false

      base: 'OU=Department,DC=guoge,DC=com'

      user_filter: ''

      attributes:

        username: ['uid', 'userid', 'sAMAccountName']

        email:    ['mail', 'email', 'userPrincipalName']

        name:       'cn'

        first_name: 'givenName'

        last_name:  'sn'

  EOS

说明:base属性执行所有员工,user_filter属性主要用来实现分组功能。上面的配置是只有ldap中的gitlab分组中的用户可以登录GitLab。

2、执行gitlab-ctl reconfigure命令重新加载GitLab配置;

猜你喜欢

转载自blog.csdn.net/chanjingyue/article/details/80523600