在CentOS上配置GitLab涉及多個步驟,包括安裝必要的軟件包、配置網絡設置、設置郵件服務、安裝GitLab軟件包以及修改配置文件等。以下是詳細的步驟:
首先,更新系統并安裝必要的依賴包:
sudo yum update -y
sudo yum install -y curl policycoreutils-python openssh-server postfix wget vim
配置防火墻以允許HTTP和HTTPS流量:
sudo yum install firewalld -y
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
安裝并配置Postfix郵件服務器以發送GitLab通知郵件:
sudo yum install postfix -y
sudo systemctl enable postfix
sudo systemctl start postfix
在/etc/gitlab/gitlab.rb文件中配置郵件服務,例如使用QQ郵箱:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "your_email@example.com"
gitlab_rails['smtp_password'] = "your_password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = 'your_email@example.com'
gitlab_rails['smtp_domain'] = "example.com"
執行gitlab-ctl reconfigure使配置生效:
sudo gitlab-ctl reconfigure
添加GitLab的RPM鏡像源并安裝GitLab軟件包:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-17.3.1-ce.0.el7.x86_64.rpm
sudo rpm -i gitlab-ce-17.3.1-ce.0.el7.x86_64.rpm
修改GitLab的配置文件/etc/gitlab/gitlab.rb,設置外部URL和其他配置項:
sudo vim /etc/gitlab/gitlab.rb
例如,設置外部URL為http://your_server_ip:8080,并保存退出。
執行gitlab-ctl reconfigure使配置生效:
sudo gitlab-ctl reconfigure
啟動GitLab服務并設置為開機自啟動:
sudo gitlab-ctl start
sudo systemctl enable gitlab-ce
完成上述步驟后,通過指定的服務器IP地址和端口號訪問GitLab界面。初次登錄時,使用預設的初始賬戶名(root)和默認密碼(5iveL!fe),首次登錄后系統會要求您更改密碼。
請注意,以上步驟可能會隨著GitLab版本的更新而有所變化,建議參考GitLab的官方文檔或最新的安裝指南進行操作。