建立 GitLab 私人仓库

4 年前(已编辑)
790
这篇文章上次修改于 3 年前,可能部分内容已经不适用,如有疑问可询问作者。

今天注册了一个 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 加入

nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80

完事之后再执行 gitlab-ctl reconfigure。然后 gitlab-ctl restart 等待服务全部开起来,否则直接进入会 502,可以使用 gitlab-ctl status 查看服务有没有全部跑起来。

➜  ~ gitlab-ctl status
run: alertmanager: (pid 31708) 8066s; run: log: (pid 12366) 9529s
run: crond: (pid 31720) 8066s; run: log: (pid 31564) 8315s
run: gitaly: (pid 31730) 8065s; run: log: (pid 31542) 9684s
run: gitlab-monitor: (pid 31757) 8065s; run: log: (pid 12097) 9555s
run: gitlab-workhorse: (pid 31765) 8065s; run: log: (pid 8138) 9600s
run: grafana: (pid 31777) 8064s; run: log: (pid 14818) 9454s
run: logrotate: (pid 22099) 864s; run: log: (pid 10181) 9569s
run: nginx: (pid 31793) 8063s; run: log: (pid 8337) 9595s
run: node-exporter: (pid 31799) 8063s; run: log: (pid 10526) 9563s
run: postgres-exporter: (pid 31805) 8062s; run: log: (pid 12586) 9523s
run: postgresql: (pid 31853) 8062s; run: log: (pid 31864) 9673s
run: prometheus: (pid 31901) 8062s; run: log: (pid 12220) 9537s
run: redis: (pid 31912) 8061s; run: log: (pid 31337) 9690s
run: redis-exporter: (pid 31916) 8061s; run: log: (pid 12165) 9546s
run: sidekiq: (pid 31922) 8060s; run: log: (pid 7925) 9607s
run: unicorn: (pid 31928) 8060s; run: log: (pid 7715) 9616s

后续

建立交换空间

因为 GitLab 使用内存较大,可以建立大一点的交换空间。如下命令将会建立大约 5G swap 并挂载。

dd if=/dev/zero of=/var/swap bs=1024 count=5120000
mkswap /var/swap
echo '/var/swap  swap swap defaults 0 0' >> /etc/fstab
swapon -a
swapon -s
free -m

首次登录 GitLab

提示建立 Root 密码,以后用 Username: root,和刚刚设定的密码就是管理员登陆。

其他

评论区加载中...