git安装
新建 /etc/yum.repos.d/gitlab_gitlab-ce.repo,内容为
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
安装依赖
sudo yum install curl openssh-server openssh-clients postfix cronie
sudo service postfix start
sudo chkconfig postfix on
#这句是用来做防火墙的,避免用户通过ssh方式和http来访问。
sudo lokkit -s http -s ssh
再执行
sudo yum makecache
sudo yum install gitlab-ce
sudo gitlab-ctl reconfigure #Configure and start GitLa
配置域名: vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
# 外网访问的端口,如果服务器已经有服务器占用了80,那么这里可以改成其它
listen *:8888;
server_name gitlab.gaby.com;
set $http_host_with_default "gitlab.gaby.com:8888";
补充说明:因为编译gitlab的配置 /etc/gitlab/gitlab.rb 时会重新生成这个自定义nginx 配置,所以只要 gitlab 的配置配得好,上面的nginx其实不需要自定义的。
修改密码
gitlab-rails console production
user = User.where(id:1).first
#建议八位起
user.password='123456'
user.save!
GitLab配置文件修改
vim /etc/gitlab/gitlab.rb
gitlab基本配置
#外部访问url(经过编译后,自动将这个配置编译到nginx配置,nginx就无需配置了)
external_url 'http://gitlab.test.domain.com:8888'
#默认值就是8080。如果端口被占用,可将8080修改为其它(例如:9090)
unicorn['port'] = 8080
配置生效
#使配置生效
gitlab-ctl reconfigure
#重新启动GitLab
gitlab-ctl restart
GitLab常用命令
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
vim /etc/gitlab/gitlab.rb # 修改gitlab配置文件;
gitlab-ctl reconfigure # 重新编译gitlab的配置;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;
gitlab-ctl tail nginx/gitlab_access.log
git使用
登录网址:http://gitlab.gaby.com:8888
注意:第一次访问的时候,会让你修改密码。
创建分组
楼主也是刚入门写的这篇文章,本人是认为分组可能是为了管理项目用的。
创建项目
当你创建好了分组后,在分组内创建项目。
移除项目
点击到项目中,选择左侧的setting。
选择Advanced,点开之后最下面有一个remove Project按钮。
创建用户
用管理员身份进入gitlab之后,选择上方的一个小工具图标,进入管理界面。
选择Users即可添加用户。
注意的是,这里添加完之后只是填写了姓名,帐号,邮箱,密码是通过邮箱验证然后修改的,如果不需要这么麻烦的话,就创建用户后,用上面修改密码的命令找到指定的user,设置密码即可。
给项目添加用户
在项目的setting中有一个members。
给用户添加push主分支的权限
在左侧的Respository中选择,然后点击Protected Branches一项中可以修改分支的权限。将权限分配给指定的角色。