Centos7 搭建gitlab服务器

                          Centos7 搭建gitlab服务器

本文介绍在Centos7上搭建gitlab服务器,网上看到几篇帖子,跟着试了试没成功,尤其是下面的第三步没有跟整个教程串起来,好了不bibi了。

进入正题:

参考:gitlab官方链接:https://about.gitlab.com/downloads/#centos7
blog链接:http://blog.csdn.net/yulei_qq/article/details/53033381
gitlab.com链接:https://gitlab.com/gitlab-org/omnibus-gitlab/issues/2051

1.安装和配置依赖:

sudo yum install curl policycoreutils openssh-server openssh-clients  
sudo systemctl enable sshd  
sudo systemctl start sshd  
sudo yum install postfix  
sudo systemctl enable postfix  
sudo systemctl start postfix  
sudo firewall-cmd --permanent --add-service=http  
sudo systemctl reload firewalld  

2.下载gitlab包:

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash  
sudo yum install gitlab-ce  

3.修改external_url:

完成上面的1和2,不要急着编译,先打开 /etc/gitlab/gitlab.rb ,搜索external_url,应该是这样的:
external_url :'110.120.119.911’,我们将其改成这样的 :external_url = ‘YOUR IP’,注意中间的“”=“”号。
保存,退出。

4.编译运行:

sudo gitlab-ctl reconfigure

如果没有报错,最后提示类似下面的,就算是成功了:

Running handlers complete
Chef Client finished

5.用浏览器打上你的ip地址或者域名,即可看到你期待已久的页面:

这里写图片描述

第一次会提示一个修改密码的页面,和这个一样的界面,输入密码,然后确认密码,登录就ok,username是root

错误解决:

如果你在执行第四步的时候遇到如下问题:

Recipe: gitlab::selinux

  • execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp] action runsemodule: relocation error: semodule: symbol semanage_module_info_get_version, version LIBSEMANAGE_1.1 not defined in file libsemanage.so.1 with link time reference

    [execute] semodule: relocation error: semodule: symbol semanage_module_info_get_version, version LIBSEMANAGE_1.1 not defined in file libsemanage.so.1 with link time reference

    ================================================================================
    Error executing action run on resource 'execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp]'

    Mixlib::ShellOut::ShellCommandFailed

    Expected process to exit with [0], but received ‘127’
    ---- Begin output of semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp ----
    STDOUT:
    STDERR: semodule: relocation error: semodule: symbol semanage_module_info_get_version, version LIBSEMANAGE_1.1 not defined in file libsemanage.so.1 with link time reference
    ---- End output of semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp ----
    Ran semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp returned 127

    Resource Declaration:

    In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/selinux.rb

    20: execute “semodule -i /opt/gitlab/embedded/selinux/rhel/7/#{ssh_keygen_module}.pp” do
    21: not_if “getenforce | grep Disabled”
    22: not_if “semodule -l | grep ‘^#{ssh_keygen_module}\s’”
    23: end
    24: end

    Compiled Resource:

    Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/selinux.rb:20:in `from_file’

    execute(“semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp”) do
    action [:run]
    retries 0
    retry_delay 2
    default_guard_interpreter :execute
    command “semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp”
    backup 5
    returns 0
    declared_type :execute
    cookbook_name “gitlab”
    recipe_name “selinux”
    not_if “getenforce | grep Disabled”
    not_if “semodule -l | grep ‘^gitlab-7.2.0-ssh-keygen\s’”
    end

    Platform:

    x86_64-linux

Running handlers:
Running handlers complete
Chef Client failed. 3 resources updated in 03 seconds

(怎么设置文字颜色,欢迎留言教我,懒得查了)

出现这个问题,请参考上面链接中的第三个。

这个问题的解决:
执行下面这条命令即可,安装这个包,具体干嘛用的没查

sudo yum install libsemanage-static libsemanage-devel

then:

重新 sudo gitlab-ctl reconfigure 就可以了.

如果这个方法没有解决你的问题,请搜索关键词:

Error executing actionrunon resource 'execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp]'

and:

gitlab Chef Client failed

gitlab使用:

说一下登录gitlab之后,用户权限分配以及配置ssh秘钥和常用的客户端push会遇到的问题:

1.本地需要有git服务器;
2.本地生成ssh秘钥并配置到gitlab服务器;

http://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html

3.gitlab上创建group;

4.在group中创建项目;

创建组和项目的时候,注意设置一下Visibility Level,具体的不说了,页面上都有解释;创建之后也可以改

5.设置成员;

5.1创建好组和项目之后,选择project,setting:

这里写图片描述

5.2

这里写图片描述

第一个箭头:搜索本服务器上的其他成员,在gitlab服务器搭建好之后,其他人可以通过浏览器访问此服务器选择注册账号,然后根据上述步骤创建ssh秘钥并配置到gitlab 自己的账号下,然后root管理员或者其他成员在创建项目之后可以点击下拉列表看到本服务器下的成员选择添加

第二个箭头:用户等级,权限,具体可点击readmore查看详情

第三个箭头:添加此成员到项目中;

至于上面那个date,是设置此成员访问此项目的期限,有需要的可以设置

注意:

1.第一次创建空的项目,创建者需要往里添加至少一个文件,例如README.TXT即可,其实是需要创建一个分支,可以在浏览器中直接创建,也可在git bash等工具中创建,

cd 一个目录; git init git remote add origin 地址 touch README.txt git add . git commit git push -u origin master

2.其他用户push权限设置:
当项目中的其他成员push代码的时候,可能遇到下面的错误:

`Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists`

这是因为项目创建者没有设置其他参与者的push等权限

进到浏览器,project --setting --repository

这里写图片描述

第一个箭头:如果在上面添加成员了,这里不用管,这是根据秘钥添加成员的方式;
下面的两个箭头: 如果刚创建项目,并没有进行一次提交或者创建分支,这里是不会出现的,只有在创建分支之后才会出现这个默认的 保护分支栏目,allowed to merge,allowed to push分别用来设置组员管理和push权限,点击下拉列表选择即可。

你也可以自己创建一个保护分支,页面上的绿色字体Wildcards有具体介绍。

现在试试pull和push应该就没问题了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Code王工

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值