GitLab在Linux上的部署流程大致可以分為以下幾個步驟:
主機名更改:
sudo hostnamectl set-hostname gitlab
防火墻配置:
對于Ubuntu,使用 ufw
命令:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
對于CentOS,使用 firewalld
命令:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
關閉SELinux:
sudo sed -i 's/selinux=enforcing/selinux=disabled/g' /etc/sysconfig/selinux
sudo setenforce 0
設置EPEL源、安裝基本操作命令:
對于Ubuntu:
sudo apt-get update
sudo apt-get install -y wget
wget -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sudo apt-get install -y net-tools vim lrzsz tree screen lsof tcpdump ntpdate
對于CentOS:
sudo yum install -y wget
wget -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sudo yum install -y net-tools vim lrzsz tree screen lsof tcpdump ntpdate
時間同步:
sudo cp /usr/share/zoneinfo/asia/shanghai /etc/localtime
echo "*/5 * * * * ntpdate time1.aliyun.com &> /dev/null && hwclock -w" >> /var/spool/cron/root
sudo systemctl restart crond
下載軟件官方源或鏡像源:
安裝依賴包:
sudo apt-get install -y curl policycoreutils-python openssh-server
添加GitLab軟件包倉庫:
對于Ubuntu:
curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
對于CentOS:
curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
安裝GitLab:
sudo apt-get update
sudo apt-get install -y gitlab-ce
或
sudo yum install -y gitlab-ce
配置并啟動GitLab:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
訪問GitLab:
打開瀏覽器,輸入你的服務器IP地址或域名進行訪問,初始賬戶為 root
,密碼為 5iveL!fe
,首次登錄后會提示修改密碼。
修改管理員密碼:
在個人賬戶頁面中修改密碼。
配置SMTP服務:
在員工設置中選擇郵件通知,然后輸入SMTP服務器相關信息。
使用自簽名SSL證書:
在瀏覽器中訪問信任的HTTPS網站時,需要使用SSL證書。GitLab在默認情況下使用自簽名證書,用于建立HTTPS連接。
以上步驟是在Linux系統上部署GitLab的基本流程,具體操作可能會因Linux發行版和具體需求有所不同。在部署前,請確保你的服務器滿足GitLab的系統要求,并參考GitLab的官方文檔進行詳細配置。