# GitLab

# Install Gitlab Self host and Git Runner

For Ubuntu 20.04 and 22.04, `arm64` packages are also available and will be automatically used on that platform when using the GitLab repository for installation.

#### 1. Install and configure the necessary dependencies

```
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
```

<span style="white-space: pre-wrap;">Next, install Postfix (or Sendmail) to send notification emails. If you want to use another solution to send emails please skip this step and </span>[configure an external SMTP server after GitLab has been installed](https://docs.gitlab.com/omnibus/settings/smtp)

```
sudo apt-get install -y postfix
```

During Postfix installation a configuration screen may appear. Select '<span style="color: rgb(229, 158, 37);">Internet Site</span><span style="white-space: pre-wrap;">' and press enter. </span><span style="color: rgb(229, 158, 37);">Use your server's external DNS for 'mail name' and press enter.</span><span style="white-space: pre-wrap;"> If additional screens appear, continue to press enter to accept the defaults.</span>

#### 2. Add the GitLab package repository and install the package

```
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
```

<span style="white-space: pre-wrap;">Next, install the GitLab package. Make sure you have correctly </span>[set up your DNS](https://docs.gitlab.com/omnibus/settings/dns)<span style="white-space: pre-wrap;">, and change </span><span style="color: rgb(229, 158, 37);">https://gitlab.example.com</span><span style="white-space: pre-wrap;"> to the URL at which you want to access your GitLab instance. Installation will automatically configure and start GitLab at that URL.</span>

<span style="white-space: pre-wrap;">For https:// URLs, GitLab will automatically </span>[request a certificate with Let's Encrypt](https://docs.gitlab.com/omnibus/settings/ssl/index.html#lets-encrypthttpsletsencryptorg-integration)<span style="white-space: pre-wrap;">, which requires inbound HTTP access and a </span>[valid hostname](https://docs.gitlab.com/omnibus/settings/dns)<span style="white-space: pre-wrap;">. You can also </span>[use your own certificate](https://docs.gitlab.com/omnibus/settings/nginx.html#manually-configuring-https)or just use http:// (without the s ).

<span style="white-space: pre-wrap;">If you would like to specify a custom password for the initial administrator user ( root ), check the </span>[documentation](https://docs.gitlab.com/omnibus/installation/index.html#set-up-the-initial-password). If a password is not specified, a random password will be automatically generated.

```
sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee
# List available versions: apt-cache madison gitlab-ee
# Specifiy version: sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install gitlab-ee=16.2.3-ee.0
# Pin the version to limit auto-updates: sudo apt-mark hold gitlab-ee
# Show what packages are held back: sudo apt-mark showhold
```

<span style="white-space: pre-wrap;">Unless you provided a custom password during installation, a </span><span style="color: rgb(229, 158, 37);">password will be randomly generated and stored for 24 hours</span><span style="white-space: pre-wrap;"> in </span><span style="color: rgb(229, 158, 37);">/etc/gitlab/initial\_root\_password</span>. Use this password with username root to login.

<span style="white-space: pre-wrap;">See our </span>[documentation for detailed instructions on installing and configuration.](https://docs.gitlab.com/omnibus/README.html#installation-and-configuration-using-omnibus-package)

#### 4. Set up your communication preferences

<span style="white-space: pre-wrap;">Visit our </span>[email subscription preference center](https://about.gitlab.com/company/preference-center/)to let us know when to communicate with you. We have an explicit email opt-in policy so you have complete control over what and how often we send you emails.

Twice a month, we send out the GitLab news you need to know, including new features, integrations, docs, and behind the scenes stories from our dev teams. For critical security updates related to bugs and system performance, sign up for our dedicated security newsletter.

****Important Note**** If you do not opt-in to the security newsletter, you will not receive security alerts.

#### 5. Recommended next steps

<span style="white-space: pre-wrap;">After completing your installation, consider the </span>[recommended next steps, including authentication options and sign-up restrictions.](https://docs.gitlab.com/ee/install/next_steps.html)

#### 6. Install and configure GitLab-Runner

<span style="white-space: pre-wrap;">source: </span>[here](https://docs.gitlab.com/runner/install/)

- Download binary for linux 64  
    `<span class="editor-theme-code">sudo curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"</span>`
- Set Permission to exec.  
    `<span class="editor-theme-code">sudo chmod +x /usr/local/bin/gitlab-runner</span>`
- Create Gitlab-Runner user  
    `<span class="editor-theme-code">sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash</span>`
- Install and run as service  
    `<span class="editor-theme-code">sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner</span>`  
    `<span class="editor-theme-code">sudo gitlab-runner start</span>`
- Register with Gitlab-Project.  
    <span style="white-space: pre-wrap;">Open gitlab project repo. </span>****Settings****<span style="white-space: pre-wrap;"> &gt; </span>****CI/CD****<span style="white-space: pre-wrap;"> &gt; </span>****Runners****<span style="white-space: pre-wrap;"> &gt; </span>****New project runner****<span style="white-space: pre-wrap;"> &gt; Select linux as </span>****Operating system****<span style="white-space: pre-wrap;"> &gt; select "</span>****Run untagged jobs****<span style="color: rgb(51, 50, 56);">"</span><span style="white-space: pre-wrap;"> &gt; </span>****Create runner****. register command and token are generated. run this command on gitlab-runner host.

#### 7. Cheat sheet and sample config

if you lose your root password, here how to reset root password:

`<span class="editor-theme-code">sudo gitlab-rake "gitlab:password:reset"</span>`

<span style="white-space: pre-wrap;"></span>

<span style="white-space: pre-wrap;">sample config, Gitlab running behind </span>`<span class="editor-theme-code">Reverse Proxy Server</span>`<span style="white-space: pre-wrap;"> with </span>`<span class="editor-theme-code">SSL</span>`<span style="white-space: pre-wrap;"> terminate:</span>

```
external_url 'https://gitlab.celepuk.com'
nginx['listen_port'] = 80
nginx['listen_https'] = false
```

Sample config

Sample nginx Reverse Proxy config:

```
server {
      listen 4430 ssl;
      server_name gitlab.celepuk.com;
      location / {
                  proxy_pass http://192.168.0.206:80;
                  proxy_set_header X-Forwarded-For "";
                  proxy_set_header Host $host;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header Forwarded proto=$scheme;
                  proxy_set_header X-Forwarded-Ssl on;
                  }
}
```