1、下载跟Linux版本相关的.rpm包
地址:https://packages.gitlab.com/gitlab/gitlab-ce

2、将下载的rpm包上传到机器

3、使用rpm安装
rpm -ivh ~~gitlab-ce-15.6.2-ce.0.el7.x86_64.rpm~~ 此处解压的包名需要换成下载的名称

rpm -ivh gitlab-ce-16.3.5-ce.0.el7.x86_64.rpmwarning: gitlab-ce-16.3.5-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEYPreparing... ################################# [100%]Updating / installing...1:gitlab-ce-16.3.5-ce.0.el7 ################################# [100%]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 reconfigureFor a comprehensive list of configuration options please see the Omnibus GitLab readmehttps://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.mdHelp us improve the installation experience, let us know how we did with a 1 minute survey:https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-3
根据启动成功后的提示语修改相应的配置。
4、安装完成后修改配置文件
(1)vim /etc/gitlab/gitlab.rb
(2)找到 external_url ‘http://gxitlab.example.com‘
(3)替换为你自己的IP和端口。 样例:

5、重置并启动
第一步刷新配置:gitlab-ctl reconfigure (需等待一会,3-5分钟)
第二步重新启动: gitlab-ctl restart (需等待一会,3-5分钟)
刷新配置:gitlab-ctl reconfigure时遇到报错

解决办法:
[2023-10-08T10:21:32+08:00] INFO: file[/var/opt/gitlab/gitlab-kas/authentication_secret_file] sending restart action to runit_service[gitlab-kas] (delayed)Recipe: gitlab-kas::enable* runit_service[gitlab-kas] action restart================================================================================Error executing action `restart` on resource 'runit_service[gitlab-kas]'================================================================================Mixlib::ShellOut::ShellCommandFailed------------------------------------Expected process to exit with [0], but received '1'---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----STDOUT: fail: /opt/gitlab/service/gitlab-kas: runsv not runningSTDERR:---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas returned 1Cookbook Trace: (most recent call first)----------------------------------------/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/helpers.rb:136:in `safe_sv_shellout!'/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/helpers.rb:164:in `restart_service'/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb:368:in `block in <class:RunitService>'Resource Declaration:---------------------suppressed sensitive resource outputCompiled Resource:------------------suppressed sensitive resource outputSystem Info:------------chef_version=17.10.0platform=centosplatform_version=7.6.1810ruby=ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]program_name=/opt/gitlab/embedded/bin/cinc-clientexecutable=/opt/gitlab/embedded/bin/cinc-clientRunning handlers:[2023-10-08T10:21:32+08:00] ERROR: Running exception handlersThere was an error running gitlab-ctl reconfigure:runit_service[gitlab-kas] (gitlab-kas::enable line 148) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----STDOUT: fail: /opt/gitlab/service/gitlab-kas: runsv not runningSTDERR:---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas returned 1Running handlers complete[2023-10-08T10:21:32+08:00] ERROR: Exception handlers complete
之后再重启Gitlab
chmod 0755 /var/opt/gitlab/postgresqlsystemctl restart gitlab-runsvdir
gitlab-ctl reconfiguregitlab-ctl restart

可以发现所有相关的服务都在正常运行。
6、访问
访问地址为第四步在配置文件中配置的IP和端口
需要关闭防火墙或者开放填写的端口。关闭防火墙命令:systemctl stop firewalld
:::warning
在启动Gitlab的时候访问是会提示502 Whoops, GitLab is taking too much time to respond.
:::
账号为:root
密码为:cat /etc/gitlab/initial_root_password 文件中的Password
:::color5 注意:初始化密码文件会在24小时后被清理,及时查看初始化密码。
:::

7、卸载步骤
- 停止Gitlab服务:
sudo gitlab-ctl stop
- 卸载Gitlab:
sudo rpm -e gitlab-ce
- 查看Gitlab进程:
ps -ef | grep gitlab

kill -9 <进程ID>
- 再次查看Gitlab进程是否存在:
ps -ef | grep gitlab
- 删除Gitlab文件:
find / -name *gitlab* | xargs rm -rf
