Debian13安装GitLab

115 阅读2分钟

使用的系统

root@gitlab:~# uname -a
Linux gitlab 6.12.48+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.48-1 (2025-09-20) x86_64 GNU/Linux
root@gitlab:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
Codename:       trixie

安装curl

如果系统没有curl命令的话需要先安装下curl

# 没有sudo的话先安装个sudo
apt install sudo -y

sudo apt install -y curl

添加GitLab软件源

curl "https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh" | sudo bash

安装GitLab

官方推荐我们配置上EXTERNAL_URL,该参数为我们电脑的IP地址,后面使用这个IP访问GitLab (此配置我配置了没有生效注意参考错误二)

EXTERNAL_URL="http://192.168.0.17"
apt install gitlab-ce

配置初始化gitlab

gitlab-ctl reconfigure

创始化完成后我们就可以访问页面了

  • 登陆的用户为root
  • 登陆的初始密码在/etc/gitlab/initial_root_password文件中。

image.png

遇到的错误

错误一

使用apt update更新数据源时会报源key错误。

root@gitlab:~# apt update
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/debian trixie InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/debian trixie-updates InRelease                                    
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/debian trixie-backports InRelease                                  
Hit:4 https://security.debian.org/debian-security trixie-security InRelease                                   
Get:5 https://packages.gitlab.com/gitlab/gitlab-ce/debian trixie InRelease [23.3 kB]    
Err:5 https://packages.gitlab.com/gitlab/gitlab-ce/debian trixie InRelease
  Sub-process /usr/bin/sqv returned an error code (1), error message is: Error: Failed to parse keyring "/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg"  Caused by:     0: Reading "/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg": No such file or directory (os error 2)     1: No such file or directory (os error 2)
Warning: OpenPGP signature verification failed: https://packages.gitlab.com/gitlab/gitlab-ce/debian trixie InRelease: Sub-process /usr/bin/sqv returned an error code (1), error message is: Error: Failed to parse keyring "/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg"  Caused by:     0: Reading "/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg": No such file or directory (os error 2)     1: No such file or directory (os error 2)
Error: The repository 'https://packages.gitlab.com/gitlab/gitlab-ce/debian trixie InRelease' is not signed.
Notice: Updating from such a repository can't be done securely, and is therefore disabled by default.

image.png

错误原因是安装脚本安装的文件是在/etc/apt/keyrings/gitlab_gitlab-ce-archive-keyring.gpg目录下

image.png

解决办法,拷贝一份即可。后面随着GitLab的更新官方应该会修复这个问题。

cp  /etc/apt/keyrings/gitlab_gitlab-ce-archive-keyring.gpg /usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg

错误二

EXTERNAL_URL没有生效

解决办法修改配置文件/etc/gitlab/gitlab.rb,修改为如下内容。

image.png

参考文档