# GITLAB 建置操作手冊 ###### tags: `服務建置安裝手冊` * Amazon Linux 2 ## 注意事項 : 硬體規格最低要求( 4core / 8GB ) 1. 下載 GitLab package server ```bash=+ # sudo yum install -y curl policycoreutils-python openssh-server openssh-clients perl ``` :::info AL2023 ``` #sudo dnf install -y policycoreutils openssh-server perl ``` ::: 2. 開啟 sshd 服務 ```bash=+ # sudo systemctl enable sshd # sudo systemctl start sshd # sudo systemctl status sshd ``` 3. 安裝 Firewalld 並檢查是否關閉 ```bash=+ # sudo yum install firewalld # sudo firewall-cmd --permanent --add-service=http FirewallD is not running # sudo firewall-cmd --permanent --add-service=https FirewallD is not running # sudo systemctl reload firewalld Job for firewalld.service invalid. # systemctl stop firewalld ``` 3. 安裝 Postfix 並檢查 ```bash=+ # sudo yum install postfix # sudo systemctl enable postfix # sudo systemctl start postfix # sudo systemctl status postfix ``` 4. 拉取套件並安裝 ```bash=+ # curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash # sed -i "s/\/el\/7/\/amazon\/2/g" /etc/yum.repos.d/gitlab_gitlab*.repo # sudo EXTERNAL_URL="http://192.169.0.119" yum install gitlab-ce -y ``` * 已完成結果 ``` gitlab Reconfigured! *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! GitLab should be available at http://192.169.0.119 ``` 5. 修改配置檔 ```bash=+ # sudo vim /etc/gitlab/gitlab.rb ``` * 加入內容修改 port 80 (預設為 8080 port) ``` external_url "http://192.169.0.119:80" nginx['enable'] = true nginx['redirect_http_to_https'] = true nginx['redirect_http_to_https_port'] = 80 nginx['ssl_certificate'] = "/etc/gitlab/ssl/nginx.crt" nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/nginx.key" ``` 6. 重新讀取配置檔 & 啟動服務 ```bash=+ # sudo gitlab-ctl reconfigure # sudo gitlab-ctl restart ``` 7. 開啟 & 關閉 Gitlab 服務 ```bash=+ # sudo gitlab-ctl start # sudo gitlab-ctl stop ``` 8. 重新設定密碼 * root 密碼 ```bash=+ # sudo gitlab-rake 'gitlab:password:reset[root]' Enter username: root Enter password: Confirm password: Password successfully updated for user with username root. ``` * user 密碼 ```bash=+ # gitlab-rake "gitlab:password:reset[eva]" Enter password: Confirm password: Password successfully updated for user with username eva. ``` 9. 連線後畫面 ![](https://i.imgur.com/Zqmtugo.png) ![](https://i.imgur.com/goQb65Y.png) 10. 創建專案 ![](https://i.imgur.com/89LSsut.png) 11. Clone 專案 ![](https://i.imgur.com/BtbTlj8.png) 12. Push Code ![](https://i.imgur.com/CoJLIUR.png) ![](https://i.imgur.com/dXfJkuE.jpg)