在 Linux 上验证 GitLab 配置是否生效,通常从 服务状态、配置文件、网络端口、访问测试、日志 这几个维度来排查。下面按常见场景给你一套完整验证方法。
sudo gitlab-ctl status
✅ 正常应看到类似:
run: alertmanager: ...
run: gitaly: ...
run: gitlab-monitor: ...
run: gitlab-rails: ...
run: nginx: ...
run: postgresql: ...
run: redis: ...
run: sidekiq: ...
❌ 若有 down / failed,说明服务未启动或异常。
GitLab 的主配置文件:
/etc/gitlab/gitlab.rb
sudo gitlab-rake gitlab:env:info
或:
sudo gitlab-ctl reconfigure --dry-run
✅ 无报错说明配置语法正确
sudo gitlab-ctl reconfigure
⚠️ 修改 gitlab.rb 后必须执行
ss -lntp | grep 80
ss -lntp | grep 443
或:
netstat -lntp
✅ 应看到 nginx 监听 80 / 443
curl http://localhost
或(HTTPS):
curl -k https://localhost
✅ 返回 GitLab 登录页 HTML 即正常
浏览器访问:
http://<服务器IP>
https://<你的域名>
sudo gitlab-rake gitlab:env:info
输出示例:
System information
System: Ubuntu
Current User: git
Using RVM: no
Ruby Version: 3.x
Rails Version: 6.x
GitLab Version: 16.x
✅ 能看到版本说明 Rails 正常
git ls-remote http://localhost/yourgroup/yourrepo.git
或 SSH:
ssh -T git@localhost
✅ 应看到 GitLab 欢迎信息
sudo gitlab-ctl show-config
✅ 可用于确认 gitlab.rb 是否被正确解析
grep external_url /etc/gitlab/gitlab.rb
示例:
external_url 'https://gitlab.example.com'
grep ssl /etc/gitlab/gitlab.rb
验证证书:
openssl s_client -connect localhost:443
sudo gitlab-rake gitlab:incoming_email:check
测试发邮件:
sudo gitlab-rake gitlab:send_test_email[you@example.com]
sudo gitlab-ctl tail
只看 nginx:
sudo gitlab-ctl tail nginx
只看 rails:
sudo gitlab-ctl tail gitlab-rails
| 问题 | 排查点 |
|---|---|
| 页面打不开 | nginx 是否监听 80/443 |
| 502 | unicorn/puma 未启动 |
| 改配置不生效 | 忘记 gitlab-ctl reconfigure |
| HTTPS 无效 | 证书路径或权限 |
| 无法发邮件 | SMTP 配置 / 防火墙 |
sudo gitlab-ctl status
sudo gitlab-ctl reconfigure
curl http://localhost
sudo gitlab-rake gitlab:env:info
sudo gitlab-ctl tail
如果你愿意,可以告诉我:
我可以给你 更精确的验证步骤或排错方案。