gitlab 安装:

官方的源安装很慢,建议选择清华大学的源。链接open in new window,说明教程都有,我选择的是 debian8.

curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
1
sudo vim /etc/apt/sources.list.d/gitlab-ce.list
1

文件的内容是下面这句:

deb http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/debian jessie main

1
2

然后更新源并安装

sudo apt-get update
sudo apt-get install gitlab-ce
1
2

启动、重启、停止

gitlab-ctl start|stop|restart
1

修改访问路径:

vim /etc/gitlab/gitlab.rb
1

找到下面这句,替换为你的地址,如果外网可以访问,我只是再本机测试,所以将 gitlab.example.com 改成了 localhost

external_url "http://gitlab.example.com"
1

具体问题可以参考官方文档open in new window 修改完成后运行sudo gitlab-ctl reconfigure使配置生效。

修改默认端口,解决80端口和8080端口占用的问题:

unicorn['port'] = 8082

nginx['listen_port'] = 82 
1
2
3

禁用、启用开机自启动:

禁用:

sudo systemctl disable gitlab-runsvdir.service
1

启用:

sudo systemctl enable gitlab-runsvdir.service
1

有个问题,如果开机自启动被禁用了,那么在运行 gitlab-ctl start 的时候会失败。如果是下面的错误,说明gitlab-runsvdir.service没启动,要首先运行sudo systemctl restart gitlab-runsvdir启动它才行,然后才能运行 gitlan-ctl start|stop|restart

/opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/omnibus-ctl-0.6.0/lib/omnibus-ctl.rb:692: warning: Insecure world writable dir /usr/local/nginx/sbin in PATH, mode 042777
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running
fail: redis: runsv not running
fail: redis-exporter: runsv not running
fail: sidekiq: runsv not running
fail: unicorn: runsv not running
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

502 错误:

很多时候启动后会是502的错误,这个时候就得查看日志了,gitlab-ctl tail unicorn 或许可以帮到你,根据失败的原因,再找相应的解决办法。

Last Updated: 2021/11/28 00:58:10
Contributors: biubu