GitLab 在 Linux 上的访问方式,取决于你是访问自己部署的 GitLab,还是访问 GitLab 官方服务器(gitlab.com)。下面分情况说明:
最简单,直接浏览器访问:
https://gitlab.com
如果你在 Linux 服务器上只用命令行:
git clone https://gitlab.com/用户名/仓库名.git
如果你已经在 Linux 上安装并启动了 GitLab:
http://服务器IP
或http://域名
示例:
http://192.168.1.100
http://gitlab.example.com
✅ 首次访问会让你设置 root 管理员密码
如果 GitLab 装在本机:
http://localhost
http://127.0.0.1
例如你配置了 GitLab 的域名:
http://gitlab.example.com
需要确认:
如果访问不了,先确认 GitLab 是否在运行:
sudo gitlab-ctl status
常用命令:
# 启动
sudo gitlab-ctl start
# 重启
sudo gitlab-ctl restart
# 查看日志
sudo gitlab-ctl tail
配置文件路径:
sudo vim /etc/gitlab/gitlab.rb
常见配置项:
external_url 'http://gitlab.example.com'
修改后需要重新加载:
sudo gitlab-ctl reconfigure
git clone https://gitlab.example.com/用户名/项目.git
1️⃣ 生成 SSH key:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
2️⃣ 添加公钥到 GitLab
复制:
cat ~/.ssh/id_rsa.pub
粘贴到 GitLab:
用户 → Settings → SSH Keys
3️⃣ 使用 SSH 克隆:
git clone git@gitlab.example.com:用户名/项目.git
检查:
systemctl status gitlab-runsvdir
ss -lntp | grep 80
防火墙:
sudo ufw status
sudo ufw allow 80
sudo ufw allow 443
云服务器还要开放 安全组端口
如果你是 Docker 部署:
docker ps
访问地址一般是:
http://服务器IP:端口
示例:
http://192.168.1.100:8080
你可以直接回复我下面任意一项,我可以精准帮你解决:
1️⃣ GitLab 是 自己装的 还是 gitlab.com
2️⃣ 系统是 Ubuntu / CentOS / Debian
3️⃣ 访问时报什么错(截图或文字)
4️⃣ 是否是 Docker / 本机安装
我可以直接给你一步一步排查 ✅