Skip to content

Gitlab CE Installation

Note

The following instructions maybe outdated.

Installation Instructions

  1. Install and configure the necessary dependencies.
    # apt-get install curl openssh-server ca-certificates postfix
    
  2. Add the GitLab repository and install the gitlab-ce package.
    $ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
    
    # apt-get install gitlab-ce
    
  3. Configure Gitlab-ce
    $ sudo gitlab-ctl reconfigure
    
  4. Change configuration of "external_url".
    $ sudo nano /etc/gitlab/gitlab.rb
    
    external_url 'http://gitlab.example.com:8888'
    
  5. Edit the default Nginx configuration file to redirect traffic for http://gitlab to http://gitlab:8888.
    # nano /etc/nginx/sites-available/default
    ```conf
    server {
        listen 80;
        listen [::]:80;
    
        server_name gitlab;
        rewrite ^ http://$server_name:8888$request_uri? permanent;
    }
    
  6. Browse to the hostname and login.
    1. Username: root
    2. Password: 5iveL!fe

Note: gitlab-runner.service and gitlab-runsvdir.service must be enabled and started.

Gitlab Configuration File

gitlab.rb

external_url 'http://gitlab.example.com'
gitlab_rails['time_zone'] = 'America/Regina'
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: 'Active Directory'
  host: 'ad.example.com'
  port: 389
  uid: 'sAMAccountName'
  method: 'tls' # "tls" or "ssl" or "plain"
  bind_dn: 'CN=ldapauth,CN=System,DC=ad,DC=example,DC=com'
  password: 'put-password-here'
  active_directory: true
  allow_username_or_email_login: true
  block_auto_created_users: false
  base: 'DC=ad,DC=example,DC=com'
  user_filter: ''
EOS
 gitlab_rails['manage_backup_path'] = true
 gitlab_rails['backup_path'] = "/var/opt/gitlab/backups"
 gitlab_rails['backup_archive_permissions'] = 0644 # See: http://doc.gitlab.com/ce/raketasks/backup_restore.html#backup-archive-permissions
 gitlab_rails['backup_keep_time'] = 604800
user['username'] = "gitlab"
user['group'] = "gitlab"
web_server['external_users'] = ['www-data']
nginx['enable'] = false
nginx['listen_addresses'] = ['192.168.0.59']
mattermost_external_url = 'http://mattermost.example.com'
mattermost['enable'] = true
mattermost['email_send_email_notifications'] = true
mattermost['email_smtp_username'] = 'relay@example.com'
mattermost['email_smtp_password'] = 'put-password-here'
mattermost['email_smtp_server'] = 'mail.example.com'
mattermost['email_smtp_port'] = 587
mattermost['email_connection_security'] = 'STARTTLS'
mattermost['email_feedback_name'] = 'Gitlab Mattermost'
mattermost['email_feedback_email'] = 'webmaster@example.com'
mattermost['db2_backup_created'] = true
mattermost['db2_team_name'] = 'devops0123'
mattermost_nginx['enable'] = false

Gitlab Command Quick Reference

Command Example Description
gitlab-ctl reconfigure Reconfigure the application (re-read configuration).
gitlab-ctl restart Stop the services if they are running and then start the services.
gitlab-ctl start Start services.
gitlab-ctl status Show the status of all the services.
gitlab-ctl stop Stop the services.
gitlab-rake gitlab:check Check service configuration.
gitlab-rake gitlab:ldap:check Check LDAP configuration.