gitlab安装
虚拟机IP为192.168.36.138 2核3G
至少3G 吧,2G很卡
我的环境为ubuntu 20.04
root@lili:/etc/netplan# lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
更新系统包
root@lili:~# apt update
root@lili:~# apt upgrade -y
如果报错,可参考我的另一篇文章修改apt源为国内源
ubuntu20.04切换apt源
安装依赖
root@lili:~# apt install ca-certificates curl openssh-server postfix
在postfix安装过程中,会出现一个配置窗口,选择internet Site,然后选择OK

检查系统hostname,然后选择OK

添加gitlab apt repository
运行以下命令,会自动检测你的ubuntu版本。
root@lili:/etc/apt# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
Detected operating system as Ubuntu/focal.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/gitlab_gitlab-ce.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.
The repository is setup! You can now install packages.
安装gitlab
运行以下命令,将EXTERNAL_URL替换为你的服务器的ip或域名,将会自动安装和配置gitlab-ce
root@lili:/etc/apt#EXTERNAL_URL="http://192.168.36.138" apt install gitlab-ce
设置开机启动
root@lili:/etc/apt# systemctl enable gitlab-runsvdir.service
安装成功后

查看
root@lili:/etc/ldap# gitlab-ctl status
run: alertmanager: (pid 73025) 14267s; run: log: (pid 72895) 14299s
run: gitaly: (pid 72965) 14277s; run: log: (pid 72315) 14416s
run: gitlab-exporter: (pid 73003) 14268s; run: log: (pid 72792) 14317s
run: gitlab-kas: (pid 72980) 14270s; run: log: (pid 72530) 14374s
run: gitlab-workhorse: (pid 72988) 14270s; run: log: (pid 72677) 14334s
run: logrotate: (pid 88941) 29s; run: log: (pid 72248) 14428s
run: nginx: (pid 72687) 14331s; run: log: (pid 72707) 14327s
run: node-exporter: (pid 72998) 14269s; run: log: (pid 72783) 14322s
run: postgres-exporter: (pid 73033) 14266s; run: log: (pid 72915) 14293s
run: postgresql: (pid 72384) 14381s; run: log: (pid 72512) 14378s
run: prometheus: (pid 73011) 14267s; run: log: (pid 72853) 14305s
run: puma: (pid 72580) 14349s; run: log: (pid 72587) 14348s
run: redis: (pid 72276) 14423s; run: log: (pid 72287) 14422s
run: redis-exporter: (pid 73005) 14268s; run: log: (pid 72840) 14309s
run: sidekiq: (pid 72601) 14343s; run: log: (pid 72626) 14340s
登陆
http://192.168.36.138/users/sign_in
密码在 /etc/gitlab/initial_root_password

修改密码,我的root密码是!!!123!!!

我的gitlab版本为16

相关命令
sudo gitlab-ctl start # 启动所有 gitlab 组件;
sudo gitlab-ctl stop # 停止所有 gitlab 组件;
sudo gitlab-ctl restart # 重启所有 gitlab 组件;
sudo gitlab-ctl status # 查看服务状态;
sudo gitlab-ctl reconfigure # 启动服务;
sudo vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
sudo gitlab-ctl tail # 查看日志;502的时候,就从这里找问题
gitlab root密码忘记了
root@lili:/etc/gitlab# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [aarch64-linux]
GitLab: 16.4.1 (e6801ed8d44) FOSS
GitLab Shell: 14.28.0
PostgreSQL: 13.11
------------------------------------------------------------[ booted in 15.77s ]
Loading production environment (Rails 7.0.6)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = '!!!123!!!'
=> "!!!123!!!"
irb(main):003:0> user.password_confirmation = '!!!123!!!'
=> "!!!123!!!"
irb(main):004:0> user.save!
=> true
irb(main):005:0> quit