在Linux上快速部署GitLab可以通过多种方式进行,以下是使用Docker Compose进行快速搭建的步骤:
环境准备
- 操作系统:推荐使用Ubuntu或CentOS等主流Linux发行版。
- 内存:至少2GB RAM(推荐4GB或更多)。
- 存储空间:至少20GB的可用存储空间(根据需求可适当增加)。
- 网络:确保服务器能够访问互联网,并且防火墙设置允许HTTP(80端口)和HTTPS(443端口)的访问。
安装依赖
对于 Ubuntu 服务器:
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
对于 CentOS 服务器:
sudo yum update
sudo yum install -y curl policycoreutils-python openssh-server postfix
添加GitLab存储库
对于 Ubuntu/Debian:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
对于 CentOS/RHEL:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
安装GitLab
对于 Ubuntu/Debian:
sudo apt-get install gitlab-ce
对于 CentOS/RHEL:
sudo yum install gitlab-ce
配置GitLab
- 启动容器:
docker-compose up -d
- 设置外部URL:
编辑 /etc/gitlab/gitlab.rb 文件,设置外部URL:
sudo vi /etc/gitlab/gitlab.rb
找到 external_url 'http://your_server_IP',修改为你的服务器IP地址或域名。
- 重新配置GitLab:
sudo gitlab-ctl reconfigure
- 重启GitLab:
sudo gitlab-ctl restart
- 访问GitLab:
在浏览器中输入设置的外部URL,登录到GitLab控制台。默认用户名为"root",密码为初始配置的密码。
请注意,以上步骤可能会因Linux发行版和版本的不同而有所差异,建议参考GitLab官方文档或相关社区论坛获取更详细的安装指南。