今天注册了一个 DigitalOcean 账号,首充5刀返了50刀,但是只有1个月的期限。闲着也是闲着,我就开了一台 $20/mo 的机子耍耍。配置是 4G RAM,2 core CPU,40G SSD。用来建私人 GitLab 正好。
官网讲的很详细了,跟着步骤走就行了。
https://about.gitlab.com/install/
注意的是,这里记得换成自己的域名,在此之前,需要把域名解析到这台机器的 IP。因为它使用的是 Let's encrypt
如果签发 SSL 证书失败,可能是你安装了其他的 nginx
导致,首先把 nginx 服务停止。service nginx stop
,然后再 gitlab-ctl reconfigure
。
再不行就打开 /etc/gitlab/gitlab.rb
加入
1nginx['redirect_http_to_https'] = true
2nginx['redirect_http_to_https_port'] = 80
COPY
完事之后再执行 gitlab-ctl reconfigure
。然后 gitlab-ctl restart
等待服务全部开起来,否则直接进入会 502
,可以使用 gitlab-ctl status
查看服务有没有全部跑起来。
bash
1➜ ~ gitlab-ctl status
2run: alertmanager: (pid 31708) 8066s; run: log: (pid 12366) 9529s
3run: crond: (pid 31720) 8066s; run: log: (pid 31564) 8315s
4run: gitaly: (pid 31730) 8065s; run: log: (pid 31542) 9684s
5run: gitlab-monitor: (pid 31757) 8065s; run: log: (pid 12097) 9555s
6run: gitlab-workhorse: (pid 31765) 8065s; run: log: (pid 8138) 9600s
7run: grafana: (pid 31777) 8064s; run: log: (pid 14818) 9454s
8run: logrotate: (pid 22099) 864s; run: log: (pid 10181) 9569s
9run: nginx: (pid 31793) 8063s; run: log: (pid 8337) 9595s
10run: node-exporter: (pid 31799) 8063s; run: log: (pid 10526) 9563s
11run: postgres-exporter: (pid 31805) 8062s; run: log: (pid 12586) 9523s
12run: postgresql: (pid 31853) 8062s; run: log: (pid 31864) 9673s
13run: prometheus: (pid 31901) 8062s; run: log: (pid 12220) 9537s
14run: redis: (pid 31912) 8061s; run: log: (pid 31337) 9690s
15run: redis-exporter: (pid 31916) 8061s; run: log: (pid 12165) 9546s
16run: sidekiq: (pid 31922) 8060s; run: log: (pid 7925) 9607s
17run: unicorn: (pid 31928) 8060s; run: log: (pid 7715) 9616s
COPY
因为 GitLab 使用内存较大,可以建立大一点的交换空间。如下命令将会建立大约 5G swap 并挂载。
bash
1dd if=/dev/zero of=/var/swap bs=1024 count=5120000
2mkswap /var/swap
3echo '/var/swap swap swap defaults 0 0' >> /etc/fstab
4swapon -a
5swapon -s
6free -m
COPY
提示建立 Root 密码,以后用 Username: root
,和刚刚设定的密码就是管理员登陆。