How to install/setup GitLab

## Install and configure the necessary dependencies

##### ssh

    # yum install openssh-server openssh-clients
    # systemctl enable sshd
    # systemctl start sshd
    # systemctl list-units --type=service  | grep ssh
    sshd.service                       loaded active running OpenSSH server daemon

##### postfix

    # yum install postfix
    # systemctl enable postfix
    # systemctl start postfix
    # systemctl list-units --type=service  | grep postfix
    postfix.service                    loaded active running Postfix Mail Transport Agent


##### others

    # yum install curl policycoreutils

##### firewall

    # firewall-cmd --add-service=http --zone=public --permanent
    success

    # systemctl reload firewalld
    success

    # firewall-cmd --zone=public --list-services
    http ssh


##  Add the GitLab package server and install the package

    # curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

    # yum install gitlab-ce


## Configure

##### Update gitlab.rb

* MAIL

```
# vi /etc/gitlab/gitlab.rb

# diff /etc/gitlab/gitlab.rb.org /etc/gitlab/gitlab.rb
206,208c206,208
< # gitlab_rails['smtp_enable'] = true
< # gitlab_rails['smtp_address'] = "smtp.server"
< # gitlab_rails['smtp_port'] = 456
---
> gitlab_rails['smtp_enable'] = true
> gitlab_rails['smtp_address'] = <SMTP_SERVER>
> gitlab_rails['smtp_port'] = <SMTP_SERVER_PORT>
```

* Other Configuration options

[http://doc.gitlab.com/omnibus/settings/configuration.html][link-01]

##### Run configure

    # gitlab-ctl reconfigure

## Browse to the gitlab UI

    id : root
    pw : 5iveL!fe (default)


## gitlab-ctl command

##### Status

    # gitlab-ctl status
    run: logrotate: (pid 21213) 3179s; run: log: (pid 29874) 14275015s
    run: nginx: (pid 11526) 8650626s; run: log: (pid 29860) 14275017s
    run: postgresql: (pid 11535) 8650625s; run: log: (pid 29752) 14275077s
    run: redis: (pid 11537) 8650625s; run: log: (pid 29672) 14275088s
    run: sidekiq: (pid 11549) 8650625s; run: log: (pid 29845) 14275019s
    run: unicorn: (pid 11575) 8650622s; run: log: (pid 29809) 14275021s

##### Show config

    # gitlab-ctl show-config
    Starting Chef Client, version 12.4.0.rc.2
    resolving cookbooks for run list: ["gitlab::show_config"]
    Synchronizing Cookbooks:
      - package
      - runit
      - gitlab
    Compiling Cookbooks...
    {
      "gitlab": {
        "bootstrap": {

        },
        "omnibus-gitconfig": {

        },
        "user": {
          "git_user_email": "gitlab@<HOST_IP>"
        },
        "redis": {

        },
        "ci-redis": {

        },
        "gitlab-rails": {
          "smtp_enable": true,
          "smtp_address": "<SMTP_SERVER>",
          "smtp_port": 587,
          "secret_token": "**********",
          "gitlab_host": "<HOST_IP>",
          "gitlab_email_from": "gitlab@<HOST_IP>",
          "gitlab_https": false,
          "gitlab_port": 80,
          "db_username": "gitlab",
          "db_host": null,
          "db_port": 5432
        },
        "gitlab-ci": {
          "secret_token": null,
          "secret_key_base": "**********",
          "db_key_base": "**********",
          "db_username": "gitlab_ci",
          "db_host": null,
          "db_port": 5432
        },
        "gitlab-shell": {
          "secret_token": "**********"
        },
        "unicorn": {

        },
        "ci-unicorn": {

        },
        "sidekiq": {

        },
        "ci-sidekiq": {

        },
        "nginx": {
          "listen_port": 80
        },
        "ci-nginx": {
          "listen_port": 80
        },
        "logging": {

        },
        "remote-syslog": {

        },
        "logrotate": {

        },
        "high-availability": {

        },
        "postgresql": {

        },
        "web-server": {

        },
        "external-url": "http://<HOST_IP>",
        "ci-external-url": null
      }
    }
    Converging 0 resources

    Running handlers:
    Running handlers complete
    Chef Client finished, 0/0 resources updated in 1.889371755 seconds


##### Service list

    # gitlab-ctl service-list
    logrotate*
    nginx*
    postgresql*
    redis*
    sidekiq*
    unicorn*

##### Show log

    # gitlab-ctl tail <SERVICE_NAME>

    ex) gitlab-ctl tail nginx

##### Start/Stop

    # gitlab-ctl [start|stop]


## Environment

##### OS

    # cat /etc/redhat-release
    CentOS Linux release 7.1.1503 (Core)

##### Gitlab

    # rpm -q gitlab-ce
    gitlab-ce-7.13.5-ce.0.el7.x86_64

##### Nginx

    # /opt/gitlab/embedded/sbin/nginx -V
    nginx version: nginx/1.7.12
    built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
    TLS SNI support enabled
    configure arguments: --prefix=/opt/gitlab/embedded --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-ipv6 --with-debug --with-ld-opt=-L/opt/gitlab/embedded/lib --with-cc-opt='-L/opt/gitlab/embedded/lib -I/opt/gitlab/embedded/include'

##### PostgreSQL

    # /opt/gitlab/embedded/bin/psql --version
    psql (PostgreSQL) 9.2.10

##### Redis

    # /opt/gitlab/embedded/bin/redis-server --version
    Redis server v=2.8.21 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=dd0e407d8cdbadbb

## Reference

[https://about.gitlab.com/downloads/][link-02]



[link-01]:http://doc.gitlab.com/omnibus/settings/configuration.html
[link-02]:https://about.gitlab.com/downloads/