Selamat datang di panduan kami tentang cara menginstal GitLab CE di Ubuntu 22.04|20.04|18.04 sistem Linux. GitLab adalah platform berfitur lengkap untuk pengembangan perangkat lunak yang dipercepat. Ini menyediakan hingga fitur awal seperti CI / CD terintegrasi, integrasi Kubernetes, Auto DevOps, GitLab Container Registry e.t.c.
Dalam panduan kami sebelumnya, kami membahas caranya Instal Gitlab CE di CentOS / Fedora. Ikuti langkah-langkah di bawah ini untuk Menginstal Gitlab CE di Ubuntu 22.04|20.04|18.04. Server dapat berjalan di Cloud atau infrastruktur virtual premis Anda sendiri.
Step 1: Melakukan Update system & menginstall dependencies
Sebelum instalasi dilakukan, pastikan system dalam keadaan update dengan menjalankan perintah berikut :
sudo apt update && sudo apt upgrade -y
Hasil output seperti berikut :
root@masadmin:~# apt update && apt upgrade -y Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB] Get:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [109 kB] Get:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 c-n-f Metadata [30.3 kB] Get:6 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 c-n-f Metadata [488 B] Get:7 http://archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f Metadata [286 kB] Get:8 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f Metadata [8,372 B] Get:9 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,064 kB] ... ... Found linux image: /boot/vmlinuz-5.15.0-78-generic Found initrd image: /boot/initrd.img-5.15.0-78-generic Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. done Scanning processes... Scanning candidates... Scanning linux images... Restarting services... /etc/needrestart/restart.d/systemd-manager systemctl restart cron.service multipathd.service packagekit.service polkit.service snapd.service udisks2.service Service restarts being deferred: systemctl restart ModemManager.service /etc/needrestart/restart.d/dbus.service systemctl restart networkd-dispatcher.service systemctl restart systemd-logind.service systemctl restart unattended-upgrades.service systemctl restart [email protected] No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host. root@masadmin:~#
Install GitLab dependencies below:
sudo apt install -y ca-certificates curl openssh-server tzdata
Hasil output sebagai berikut :
root@masadmin:~# sudo apt install -y ca-certificates curl openssh-server tzdata Reading package lists... Done Building dependency tree... Done Reading state information... Done ca-certificates is already the newest version (20230311ubuntu0.22.04.1). ca-certificates set to manually installed. curl is already the newest version (7.81.0-1ubuntu1.10). curl set to manually installed. openssh-server is already the newest version (1:8.9p1-3ubuntu0.1). tzdata is already the newest version (2023c-0ubuntu0.22.04.2). tzdata set to manually installed. The following packages were automatically installed and are no longer required: libflashrom1 libftdi1-2 Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded. root@masadmin:~#
Step 2: Configure Postfix Send-Only SMTP Server
GitLab should be able to send emails to you on Git activities. Configure Postfix SMTP Server using the guide below:
- Install and configure Postfix as a Send-Only SMTP Server on Ubuntu
Step 3: Add the GitLab CE Repository
Install dependency packages required:
sudo apt update sudo apt install curl debian-archive-keyring lsb-release ca-certificates apt-transport-https software-properties-common -y
Hasil output sebagai berikut :
root@masadmin:~# sudo apt install curl debian-archive-keyring lsb-release ca-certificates apt-transport-https software-properties-common -y Reading package lists... Done Building dependency tree... Done Reading state information... Done lsb-release is already the newest version (11.1.0ubuntu4). lsb-release set to manually installed. ca-certificates is already the newest version (20230311ubuntu0.22.04.1). curl is already the newest version (7.81.0-1ubuntu1.10). software-properties-common is already the newest version (0.99.22.7). software-properties-common set to manually installed. The following packages were automatically installed and are no longer required: libflashrom1 libftdi1-2 Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: apt-transport-https debian-archive-keyring 0 upgraded, 2 newly installed, 0 to remove and 6 not upgraded. Need to get 92.1 kB of archives. After this operation, 347 kB of additional disk space will be used. Get:1 http://id.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.9 [1,510 B] Get:2 http://id.archive.ubuntu.com/ubuntu jammy/universe amd64 debian-archive-keyring all 2021.1.1ubuntu2 [90.6 kB] Fetched 92.1 kB in 0s (302 kB/s) Selecting previously unselected package apt-transport-https. (Reading database ... 73992 files and directories currently installed.) Preparing to unpack .../apt-transport-https_2.4.9_all.deb ... Unpacking apt-transport-https (2.4.9) ... Selecting previously unselected package debian-archive-keyring. Preparing to unpack .../debian-archive-keyring_2021.1.1ubuntu2_all.deb ... Unpacking debian-archive-keyring (2021.1.1ubuntu2) ... Setting up apt-transport-https (2.4.9) ... Setting up debian-archive-keyring (2021.1.1ubuntu2) ... Scanning processes... Scanning candidates... Scanning linux images... Running kernel seems to be up-to-date. Restarting services... Service restarts being deferred: /etc/needrestart/restart.d/dbus.service systemctl restart networkd-dispatcher.service systemctl restart systemd-logind.service systemctl restart unattended-upgrades.service systemctl restart [email protected] No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host. root@masadmin:~#
Run the script below to configure GitLab repository for Debian based systems.
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Command installation output:
Detected operating system as Ubuntu/jammy. Checking for curl... Detected curl... Checking for gpg... Detected gpg... Running apt-get update... done. Installing apt-transport-https... done. Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done. Importing packagecloud gpg key... done. Running apt-get update... done. The repository is setup! You can now install packages.
The repository contents are added to:
cat /etc/apt/sources.list.d/gitlab_gitlab-ce.list
Hasil output sebagai berikut :
root@masadmin:~# cat /etc/apt/sources.list.d/gitlab_gitlab-ce.list # this file was generated by packages.gitlab.com for # the repository at https://packages.gitlab.com/gitlab/gitlab-ce deb [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ jammy main deb-src [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ jammy main root@masadmin:~#
Step 4: Install GitLab CE on Ubuntu 22.04|20.04|18.04
Once the repository has been added, install GitLab CE on Ubuntu 22.04|20.04|18.04 using the apt
package manager command:
sudo apt update sudo apt install gitlab-ce
Installation output:
root@masadmin:~# sudo apt-get install gitlab-ce Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: libflashrom1 libftdi1-2 Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: gitlab-ce 0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded. Need to get 1,315 MB of archives. After this operation, 3,104 MB of additional disk space will be used. Get:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu jammy/main amd64 gitlab-ce amd64 16.1.2-ce.0 [1,315 MB] Fetched 1,315 MB in 12min 10s (1,800 kB/s) Selecting previously unselected package gitlab-ce. (Reading database ... 74011 files and directories currently installed.) Preparing to unpack .../gitlab-ce_16.1.2-ce.0_amd64.deb ... Unpacking gitlab-ce (16.1.2-ce.0) ... Setting up gitlab-ce (16.1.2-ce.0) ... It looks like GitLab has not been configured yet; skipping the upgrade script. *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md Help us improve the installation experience, let us know how we did with a 1 minute survey: https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-1 Scanning processes... Scanning candidates... Scanning linux images... Running kernel seems to be up-to-date. Restarting services... Service restarts being deferred: /etc/needrestart/restart.d/dbus.service systemctl restart networkd-dispatcher.service systemctl restart systemd-logind.service systemctl restart unattended-upgrades.service systemctl restart [email protected] No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host. root@masadmin:~#
Edit the GitLab configuration file to set hostname and other parameters:
$ sudo vim /etc/gitlab/gitlab.rb external_url 'http://gitlab.example.com'
Replace gitlab.example.com with valid domain for GitLab server.
root@masadmin:~# cat /etc/gitlab/gitlab.rb ## GitLab configuration settings ##! This file is generated during initial installation and **is not** modified ##! during upgrades. ##! Check out the latest version of this file to know about the different ##! settings that can be configured, when they were introduced and why: ##! https://gitlab.com/gitlab-org/omnibus-gitlab/blame/master/files/gitlab-config-template/gitlab.rb.template ##! Locally, the complete template corresponding to the installed version can be found at: ##! /opt/gitlab/etc/gitlab.rb.template ##! You can run `gitlab-ctl diff-config` to compare the contents of the current gitlab.rb with ##! the gitlab.rb.template from the currently running version. ##! You can run `gitlab-ctl show-config` to display the configuration that will be generated by ##! running `gitlab-ctl reconfigure` ##! In general, the values specified here should reflect what the default value of the attribute will be. ##! There are instances where this behavior is not possible or desired. For example, when providing passwords, ##! or connecting to third party services. ##! In those instances, we endeavour to provide an example configuration. ## GitLab URL ##! URL on which GitLab will be reachable. ##! For more details on configuring external_url see: ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab ##! ##! Note: During installation/upgrades, the value of the environment variable ##! EXTERNAL_URL will be used to populate/replace this value. ##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP ##! address from AWS. For more details, see: ##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html external_url 'http://gitlab.ocp-lab.wachid.web.id' ......
When done, start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
root@masadmin:~# sudo gitlab-ctl reconfigure [2023-07-08T05:57:41+00:00] INFO: Started Cinc Zero at chefzero://localhost:1 with repository at /opt/gitlab/embedded (One version per cookbook) Cinc Client, version 17.10.0 Patents: https://www.chef.io/patents Infra Phase starting [2023-07-08T05:57:41+00:00] INFO: *** Cinc Client 17.10.0 *** [2023-07-08T05:57:41+00:00] INFO: Platform: x86_64-linux [2023-07-08T05:57:41+00:00] INFO: Cinc-client pid: 48570 [2023-07-08T05:57:42+00:00] INFO: Setting the run_list to ["recipe[gitlab]"] from CLI options [2023-07-08T05:57:42+00:00] INFO: Run List is [recipe[gitlab]] [2023-07-08T05:57:42+00:00] INFO: Run List expands to [gitlab] [2023-07-08T05:57:42+00:00] INFO: Starting Cinc Client Run for masadmin .... .... - execute /opt/gitlab/bin/gitlab-ctl hup prometheus [2023-07-08T06:00:37+00:00] INFO: env_dir[/opt/gitlab/etc/alertmanager/env] sending restart action to runit_service[alertmanager] (delayed) Recipe: monitoring::alertmanager * runit_service[alertmanager] action restart (up to date) [2023-07-08T06:00:38+00:00] INFO: env_dir[/opt/gitlab/etc/postgres-exporter/env] sending restart action to runit_service[postgres-exporter] (delayed) Recipe: monitoring::postgres-exporter * runit_service[postgres-exporter] action restart (up to date) [2023-07-08T06:00:38+00:00] INFO: Cinc Client Run complete in 175.973876398 seconds Running handlers: [2023-07-08T06:00:38+00:00] INFO: Running report handlers Running handlers complete [2023-07-08T06:00:38+00:00] INFO: Report handlers complete Infra Phase complete, 571/1587 resources updated in 02 minutes 57 seconds Notes: Default admin account has been configured with following details: Username: root Password: You didn't opt-in to print initial root password to STDOUT. Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours. NOTE: Because these credentials might be present in your log files in plain text, it is highly recommended to reset the password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password. gitlab Reconfigured! root@masadmin:~#
root@masadmin:~# cat /etc/gitlab/initial_root_password # WARNING: This value is valid only in the following conditions # 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run). # 2. Password hasn't been changed manually, either via UI or via command line. # # If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password. Password: TQo1EneMzr4zjnJg/mjTpLUP5rCx1Y39aWwPM2D2Wv4= # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours. root@masadmin:~#
All GitLab services should be started after configuration.
root@masadmin:~# sudo gitlab-ctl status run: alertmanager: (pid 50126) 125s; run: log: (pid 49936) 162s run: gitaly: (pid 50049) 134s; run: log: (pid 49238) 272s run: gitlab-exporter: (pid 50098) 126s; run: log: (pid 49692) 182s run: gitlab-kas: (pid 50061) 128s; run: log: (pid 49440) 260s run: gitlab-workhorse: (pid 50075) 128s; run: log: (pid 49575) 200s run: logrotate: (pid 49157) 285s; run: log: (pid 49190) 282s run: nginx: (pid 49616) 196s; run: log: (pid 49661) 193s run: node-exporter: (pid 50092) 127s; run: log: (pid 49679) 188s run: postgres-exporter: (pid 50139) 124s; run: log: (pid 49957) 158s run: postgresql: (pid 49289) 267s; run: log: (pid 49356) 264s run: prometheus: (pid 50107) 126s; run: log: (pid 49879) 170s run: puma: (pid 49492) 214s; run: log: (pid 49506) 211s run: redis: (pid 49193) 279s; run: log: (pid 49212) 276s run: redis-exporter: (pid 50100) 126s; run: log: (pid 49855) 176s run: sidekiq: (pid 49510) 208s; run: log: (pid 49535) 205s root@masadmin:~#
Step 5: Access GitLab CE Web Interface
Once the installation of GitLab CE on Ubuntu 22.04|20.04|18.04 is done, open the URL http://gitlab.example.com
on your browser to finish the installation of Gitlab.
A password for root user is randomly generated and stored for 24 hours in /etc/gitlab/initial_root_password
. You can check the password with the commands below:
$ cat /etc/gitlab/initial_root_password # WARNING: This value is valid only in the following conditions # 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run). # 2. Password hasn't been changed manually, either via UI or via command line. # # If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password. Password: kOtOjWp7v70OjkjtadnSJAhcDbCNo9nTNGVC5UoSCyE= # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
Use this password with username root to login.
GitLab Dashboard should look like below.
Reset root user password
Go to root user profile > Preferences
Then Password section
Input the current password, and set new one.
Step 6: Secure Gitlab CE with SSL Certificate
Read our next article below on how to configure your GitLab server to be accessible via HTTPS
- How To Secure GitLab Server with SSL Certificate
GitLab Administrations cheats
Whenever you edit GitLab configuration file – /etc/gitlab/gitlab.rb
,reconfigure GitLab service by running:
sudo gitlab-ctl reconfigure sudo gitlab-rake gitlab:check
To check the status of all GitLab service, use:
sudo gitlab-ctl status
To stop all GitLab services, use:
sudo gitlab-ctl stop
To restart all GitLab services, use:
sudo gitlab-ctl restart
You can restart a specific service by proving service name at the end
$ sudo gitlab-ctl restart logrotate ok: run: logrotate: (pid 22824) 0s
If you need LDAP Authentication on your GitLab Server, read:
- How to Configure GitLab FreeIPA Authentication
Enjoy running GitLab on Ubuntu 22.04|20.04|18.04 server and stay connected for more informative and hands-on Linux guides.