在Linux上配置GitLab可以通过以下步骤完成:
-
安装依赖包: 对于Ubuntu/Debian系统,使用以下命令安装依赖包:
sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates postfix
对于CentOS/RHEL系统,使用以下命令安装依赖包:
sudo yum install -y curl policycoreutils-python openssh-server postfix
-
下载并安装GitLab: 使用以下命令下载GitLab安装脚本:
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:
sudo apt-get install gitlab-ce # 对于Ubuntu/Debian
或者
sudo yum install gitlab-ce # 对于CentOS/RHEL
-
配置GitLab: 设置外部URL以指定GitLab访问的地址:
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服务: 启动GitLab服务:
sudo gitlab-ctl start
设置GitLab开机自启:
sudo systemctl enable gitlab
-
访问GitLab: 在浏览器中访问服务器的IP地址或域名,即可看到GitLab的登录界面,使用管理员账号和密码进行登录。
希望这些步骤能帮助你成功在Linux上配置GitLab。如果有任何问题,请参考GitLab官方文档或相关教程。