Gitlab安装

· Read in about 2 min · (257 Words)
dev work

安装环境配置

环境配置参见Github

  • Ubuntu/Debian/CentOS/RHEL
  • Ruby (MRI) 2.3
  • Git 2.7.4+
  • Redis 2.8+
  • MySQL or PostgreSQL

安装步骤

  1. 安装相关依赖

    sudo apt-get install curl openssh-server ca-certificates
    
  2. 添加gitlab-ce到apt仓库中并安装

    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
    sudo apt-get install gitlab-ce
    
  3. 配置并启动Gitlab,配置文件位于(/etc/gitlab/gitlab.rb)

    sudo gitlab-ctl reconfigure
    

安装详解

在上面的安装步骤中,它自动化的安装了PostgreSQL, Nginx等软件。

配置相关

配置文件位于/etc/gitlab/gitlab.rb中,所有配置都在些进行修改,然后执行reconfigure命名即可生效。

  • 邮件SMTP配置

    # gitlab_rails['smtp_enable'] = true
    # gitlab_rails['smtp_address'] = "smtp.server"
    # gitlab_rails['smtp_port'] = 465
    # gitlab_rails['smtp_user_name'] = "smtp user"
    # gitlab_rails['smtp_password'] = "smtp password"
    # gitlab_rails['smtp_domain'] = "example.com"
    # gitlab_rails['smtp_authentication'] = "login"
    # gitlab_rails['smtp_enable_starttls_auto'] = true
    # gitlab_rails['smtp_tls'] = false
    # gitlab_rails['smtp_openssl_verify_mode'] = 'none' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
    # gitlab_rails['smtp_ca_path'] = "/etc/ssl/certs"
    # gitlab_rails['smtp_ca_file'] = "/etc/ssl/certs/ca-certificates.crt"
    

    将上面的注释符号#去掉,并填写相应的值即可。参见SMTP配置

  • 认证LDAP配置

    gitlab_rails['ldap_enabled'] = true
    gitlab_rails['ldap_servers'] = YAML.load <<-'EOS' # remember to close this block with 'EOS' below
    main: # 'main' is the GitLab 'provider ID' of this LDAP server
    label: 'Authenticate'
    host: 'ldap.example.com'
    port: 389
    uid: 'uid'
    method: 'plain' # "tls" or "ssl" or "plain"
    bind_dn: 'uid=root,dc=example,dc=com'
    password: '123456789'
    active_directory: false
    allow_username_or_email_login: false
    block_auto_created_users: false
    base: ''
    user_filter: ''
    attributes:
      username: ['uid', 'username', 'sAMAccountName']
      email:    ['mail', 'email', 'userPrincipalName']
      name:       'displayName'
      first_name: 'cn'
      last_name:  'sn'
    EOS
    

    按照上面的配置,进行相应的修改即可。

  • 数据库配置

    # gitlab_rails['db_adapter'] = "postgresql"
    # gitlab_rails['db_encoding'] = "unicode"
    # gitlab_rails['db_collation'] = nil
    # gitlab_rails['db_database'] = "gitlabhq_production"
    # gitlab_rails['db_pool'] = 10
    # gitlab_rails['db_username'] = "gitlab"
    # gitlab_rails['db_password'] = nil
    # gitlab_rails['db_host'] = nil
    # gitlab_rails['db_port'] = 5432
    # gitlab_rails['db_socket'] = nil
    # gitlab_rails['db_sslmode'] = nil
    # gitlab_rails['db_sslrootcert'] = nil
    
  • Redis配置

    ## Redis TCP connection
    # gitlab_rails['redis_host'] = "127.0.0.1"
    # gitlab_rails['redis_port'] = 6379
    # gitlab_rails['redis_password'] = nil
    # gitlab_rails['redis_database'] = 0
    

更多配置请查看/etc/gitlab/gitlab.rb这个文件。

使用docker进行Gitlab安装

待续

参考

Comments