ubuntu安装gitlab

ubuntu安装gitlab

说明

第一次使用。gitlab-ce版本。ubuntu16.04。

初次使用,很多地方还不熟悉,后续补充。

下载依赖项

sudo apt-get install curl openssh-server ca-certificates postfix

手动下载安装包

因为gitlab官网在国外,即便配置apt,下载仍然慢。
手动从清华源下载:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/xenial/main/g/gitlab-ce/

安装

sudo dpkg -i gitlab-ce_11.6.5-ce.0_amd64.deb

配置

改访问地址

sudo vim /etc/gitlab/gitlab.rb

将 external_url = 'http://git.example.com' 修改为自己的域名地址,例如 'http://172.90.12.34:5678'

优化
默认的配置适合高性能服务器:内存特别大,CPU特别多,使用当前gitlab服务器的人特别多。我这里个人用用,没有必要那么高的配置,个人PC机也没那么强的性能;如果不修改默认配置,内存会被耗尽、CPU占用满,都是很可能的。因此继续修改: sudo vim /etc/gitlab/gitlab.rb,取消注释并修改的内容为:

  751 unicorn['worker_processes'] = 2
  770 unicorn['worker_memory_limit_min'] = "100 * 1 << 20"
  771 unicorn['worker_memory_limit_max'] = "150 * 1 << 20"

  815 sidekiq['concurrency'] = 4

  862 postgresql['shared_buffers'] = "256MB"
  863 postgresql['max_worker_processes'] = 2

配置生效

sudo gitlab-ctl reconfigure

(第一次配置,有点慢的)

启动服务

sudo gitlab-ctl start

查看状态

sudo gitlab-ctl status

停止

sudo gitlab-ctl stop

初次使用

设定root密码
访问前面设定的external_url地址,提示输入密码和再次输入密码。这其实是设定root密码,8位或更长。
输入完毕后,用root作为用户名来登录,密码就是刚刚设置的那个。

其他问题

访问提示502
说明端口被占用了。配置文件里换掉,然后重新reconfigure

找回root密码

切换root:

sudo su

打开控制台:

gitlab-rails console -e production
#等待,直到信息加载出来

查找用户:

user = User.where(id: 1).first

重置密码,注意不要带引号,也不要设置的太复杂,搞一个8位数字就好了

user.password = 12345678
user.password_confirmation = 12345678

然后从Web页面登录,再在Web页面上重置为高强度密码一次,即可。

如果发现Web页面还是不能登录,尝试重启服务:

sudo gitlab-ctl stop
sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

You are not allowed to push code to protected branches on this project.

出现场景:给同事添加了gitlab的developer权限,但是push的时候出错了。

解决:gitlab网页端->repo->settings->repository->Protected Branches,打开developer的push权限:

ref:

posted @ 2019-01-23 10:38  ChrisZZ  阅读(483)  评论(0编辑  收藏  举报