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的官方文档进行详细配置。