---
# System prepended metadata

title: 自行架設 Gitlab 於 Amazon Linux 2
tags: [SRE]

---

# 自行架設 Gitlab 於 Amazon Linux 2
###### tags: `SRE`
## 1. 安裝依賴套件
```
sudo yum install -y curl policycoreutils-python openssh-server openssh-clients perl
# Enable OpenSSH server daemon if not enabled: sudo systemctl status sshd
sudo systemctl enable sshd
sudo systemctl start sshd
# Check if opening the firewall is needed with: sudo systemctl status firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
```

## 2. 安裝 SMTP server
```
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
```

## 3. 下載 Gitlab 安裝 script
```
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
```

## 4. 安裝 Gitlab 並設定 DNS
```
sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ee
```

## 5. 設定 root 密碼
打開網站並登入，設定新密碼。  
預設密碼位置:
```
/etc/gitlab/initial_root_password
```

使用效期只有 24 小時。