1.准备环境
gitlab只支持linux系统,本人在虚拟机下使用Ubuntu作为操作系统,gitlab镜像要使用和操作系统版本对应的版本,(ubuntu24.04,gitlab-ce_17.3.0-ce.0_amd64 .deb)
book@100ask:/$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: bionic
2.下载gitlab
gitlab官网下载速度较慢且后续配置较麻烦,所以使用清华大学镜像,网址如下
Index of /gitlab-ce/ubuntu/pool/bionic/main/g/gitlab-ce/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/bionic/main/g/gitlab-ce/
注意:ubuntu的Codename 要和镜像(选择对应类型路径下的镜像)的类型一致,比如我的是bionic
将gitlab镜像放入ubuntu某个路径下
3.安装前先安装依赖
安装邮件服务的时候会出现邮件配置,使用左右键和回车键选择确定、取消,弹出列表选项的时候,选择Internet Site
sudo apt update
sudo apt install ca-certificates curl openssh-server postfix
4.在放镜像的路径操作如下命令安装gitlab
sudo pdkg -i gitlab-ce_17.3.0-ce.0_amd64
gitlib-ce 安装失败,提示GLIBC.2.25找不到,根本原因是 gitlab-ce 的版本同当前操作系统不一致。
解决方法:访问gitlab 官方服务器,直接通过下面方法进行下载安装(因为script.deb.sh脚本会判断执行curl 的操作系统的版本,根据版本更新 apt 的源);
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh |sudo bash
sudo apt-get update
sudo apt install gitlab-ce
5.安装成功提示
book@100ask:~$ sudo dpkg -i gitlab-ce_17.3.0-ce.0_amd64\ .deb
Selecting previously unselected package gitlab-ce.
(Reading database ... 133527 files and directories currently installed.)
Preparing to unpack gitlab-ce_17.3.0-ce.0_amd64 .deb ...
Unpacking gitlab-ce (17.3.0-ce.0) ...
Setting up gitlab-ce (17.3.0-ce.0) ...
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
在命令行中输入如下命令查看查看gitlab版本
ping@ping:~$ cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
17.3.0ping@ping:~$
6.安装完配置网址
修改/etc/gitlab/gitlab.rb中的external_url配置访问页面,因为我是本地的虚拟机中安装的,所以可配置虚拟机的IP地址 external_url ‘http://192.168.0.104’
book@100ask:/$ cd /etc/gitlab/
book@100ask:/etc/gitlab$ ls
gitlab.rb gitlab-secrets.json trusted-certs
book@100ask:/etc/gitlab$ sudo vim gitlab.rb
external_url 'http://192.168.0.104'
7.配置完,初始化gitlab
sudo gitlab-ctl reconfigure
8.检查gitlab是否安装好,用如下命令检查
sudo gitlab-ctl status
正常提示如下
book@100ask:/etc/gitlab$ sudo gitlab-ctl status
run: alertmanager: (pid 23499) 35390s; run: log: (pid 23133) 35508s
run: gitaly: (pid 23463) 35394s; run: log: (pid 22470) 35661s
run: gitlab-exporter: (pid 23445) 35394s; run: log: (pid 22995) 35532s
run: gitlab-workhorse: (pid 23422) 35396s; run: log: (pid 22897) 35571s
run: grafana: (pid 23596) 35389s; run: log: (pid 23355) 35425s
run: logrotate: (pid 56544) 3153s; run: log: (pid 22931) 35560s
run: nginx: (pid 22901) 35568s; run: log: (pid 22915) 35565s
run: node-exporter: (pid 23435) 35395s; run: log: (pid 22971) 35548s
run: postgres-exporter: (pid 23511) 35390s; run: log: (pid 23197) 35502s
run: postgresql: (pid 22597) 35647s; run: log: (pid 22605) 35646s
run: prometheus: (pid 23474) 35394s; run: log: (pid 23043) 35516s
run: puma: (pid 22781) 35587s; run: log: (pid 22795) 35584s
run: redis: (pid 22414) 35671s; run: log: (pid 22430) 35668s
run: redis-exporter: (pid 23454) 35395s; run: log: (pid 23014) 35521s
run: sidekiq: (pid 22798) 35581s; run: log: (pid 22810) 35578s
9.在本地window下的浏览器中输入http://192.168.0.104
10.重新设置密码
输入两次密码后,点击Change your password就可以了
或者 查找到默认密码,登录进去之后修改密码
cat /etc/gitlab/initial_root_password
11.登录使用root和刚设置的密码
12.正常登录显示
13.如果你忘记了 GitLab 的密码
-
登录到 GitLab 服务器,打开终端。
-
输入以下命令进入 GitLab 控制台:
sudo gitlab-rails console
3.如果邮箱地址不确定,可以通过数据库直接查询所有用户,知道则跳过
# 列出所有用户的邮箱列表
User.all.pluck(:email)
4.在控制台中手动验证用户是否存在
# 检查用户是否存在(替换为实际邮箱)
User.exists?(email: 'your-email@example.com')
5.密码重置
# 查找用户(确认邮箱正确)
user = User.find_by(email: 'your-email@example.com')
# 如果找到用户,重置密码(需满足密码复杂度要求)
user.password = 'new_password_123' # 至少8位,包含字母和数字
user.password_confirmation = 'new_password_123'
# 保存更改
user.save!
# 退出控制台
exit