1、安裝依賴工具
// 安裝技術依賴 yum install -y curl policycoreutils-python openssh-server // 啟動ssh服務/設置為開機啟動 sudo systemctl enable sshd sudo systemctl start sshd
2、安裝 Postfix 郵件服務器
// 安裝 postfix sudo yum install -y postfix // 啟動 postfix 並設置為開機啟動 sudo systemctl enable postfix sudo systemctl start postfix
3、安裝防火牆
yum install firewalld systemd -y
// 開放 ssh、http 服務 sudo firewall-cmd --add-service=ssh --permanent sudo firewall-cmd --add-service=http --permanent // 設置防火牆規則 sudo firewall-cmd --reload
4、添加 gitlab 鏡像源並安裝 gitlab 服務器
- 鏡像地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
- 鏡像有點大,下載比較慢,根據網速快慢,需要等幾分鍾或者十幾分鍾
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
5、安裝 gitlab
- 安裝過程需要些時間,安心等待,如果出現下圖,則說明安裝成功
rpm -ivh gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
6、安裝后修改 gitlab 配置文件,指定訪問服務器 ip 和自定義端口
// 輸入編輯命令 vim /etc/gitlab/gitlab.rb // 通過 vim 編輯命名找到 32 行 // 修改訪問 URL // 格式:external_url 'http://ip:端口' external_url 'http://119.29.xx.xxx:8081'
- 注意這里設置的端口不能被占用,默認是 8080 端口,如果 8080 已經使用,請自定義其它端口,像我這里就用了 8081 ,需要在防火牆設置開放相對應得端口
- 配置完以后還需要修改一處,去掉 puma['port'] = 8080 前面的注釋 #,並修改下端口號,注意和上面端口區分開,我這里用了 8082
// 開放 8081、8082 端口 firewall-cmd --permanent --zone=public --add-port=8081/tcp firewall-cmd --permanent --zone=public --add-port=8082/tcp // 重新加載防火牆配置 firewall-cmd --reload
7、重置 Gitlab(讓修改后的配置生效)
- 重置過程中如果出現在 action run 時卡住了情況,可以通過執行如下命令解決
- 卡住問題解決后,需要重新重置下 gitlab
- 重置過程可能需要幾分鍾,耐心等待就好!
- 出現 gitlab Reconfigured!,說明 OK 了。
// 重置 gitlab gitlab-ctl reconfigure // 解決重置過程中卡住問題 systemctl restart gitlab-runsvdir
8、啟動 gitlab 並通過 ip + 端口訪問
gitlab-ctl start // 啟動所有 gitlab 組件; gitlab-ctl stop // 停止所有 gitlab 組件; gitlab-ctl restart // 重啟所有 gitlab 組件; gitlab-ctl status // 查看服務狀態; gitlab-ctl reconfigure // 刷新配置文件; vim /etc/gitlab/gitlab.rb // 修改默認的配置文件; gitlab-rake gitlab:check SANITIZE=true --trace // 檢查gitlab; gitlab-ctl tail // 查看日志;
9、登錄 gitlab
- 賬號:root
- 密碼在文件 /etc/gitlab/initial_root_password 中查看
cat /etc/gitlab/initial_root_password