在Linux系统上安装GitLab的步骤如下:
准备工作
- 更新系统包:
sudo apt-get update sudo apt-get upgrade
- 安装依赖包:
对于Ubuntu/Debian系统:
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
对于CentOS/RHEL系统:
sudo yum install -y curl policycoreutils-python openssh-server postfix
- 设置开机自启动:
对于Ubuntu/Debian系统:
sudo systemctl enable openssh-server sudo systemctl start openssh-server
对于CentOS/RHEL系统:
sudo systemctl enable postfix sudo systemctl start postfix
- 配置防火墙:
对于Ubuntu/Debian系统(使用ufw):
sudo ufw allow 22/tcp sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable
对于CentOS/RHEL系统(使用firewalld):
sudo systemctl stop firewalld sudo systemctl disable firewalld sudo systemctl mask firewalld sudo systemctl start firewalld
安装GitLab
- 下载GitLab安装包:
对于Ubuntu/Debian系统:
curl -sS 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-ce/script.rpm.sh | sudo bash
- 安装GitLab:
对于Ubuntu/Debian系统:
sudo apt-get install -y gitlab-ce
对于CentOS/RHEL系统:
sudo yum install -y gitlab-ce
配置GitLab
- 访问GitLab:
打开浏览器,访问 http://your_server_ip
,按照提示设置管理员密码并登录。
- 修改配置:
编辑 /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
现在,您可以通过Web浏览器访问您的GitLab服务器。在浏览器中输入服务器的IP地址或域名,例如:http://your_server_ip
。在第一次访问GitLab时,您需要设置管理员密码。
以上步骤是在Linux系统上安装GitLab的基本流程,具体操作可能会因Linux发行版和版本的不同而有所差异,建议参考GitLab官方文档或相关社区论坛获取更详细的安装指南。