在Linux系统中配置GitLab涉及多个步骤,包括安装必要的软件包、配置Web服务器、设置数据库、配置GitLab以及启动服务。以下是一个基本的步骤指南:
对于 Ubuntu/Debian 系统,使用以下命令安装必要的依赖项:
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
对于 CentOS/RHEL 系统,使用以下命令安装必要的依赖项:
sudo yum update
sudo yum install -y curl policycoreutils-python openssh-server
使用官方安装包:
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo apt-get install gitlab-ce
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce
sudo gitlab-ctl reconfigure
例如:
external_url 'http://your_server_ip:port'
sudo gitlab-rails console production
在控制台中,输入以下命令修改密码:
User.where(id: 1).first.password = 'new_password'
User.where(id: 1).first.password_confirmation = 'new_password'
User.where(id: 1).first.save!
exit
启动GitLab服务:
sudo gitlab-ctl start
设置GitLab开机自启:
sudo systemctl enable gitlab
在浏览器中访问服务器的IP地址或域名,即可看到GitLab的登录界面。使用管理员账号和密码进行登录。
/etc/gitlab/gitlab.rb
中配置SMTP设置。