GitLab的安装与使用

虚拟机配置:

IP主机名主机角色内存
192.168.100.17gitlabgitlab服务端4G(虚拟机需要较高的配置)

关闭防火墙和selinux

GitLab服务器安装

1、使用yum安装依赖包

[root@gitlab ~]# yum install -y curl policycoreutils-python openssh-server wget

2、安装GitLab

[root@gitlab ~]# cd /usr/local/src
[root@gitlab src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
[root@gitlab src]# rpm -ivh gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm
warning: gitlab-ce-10.2.2-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-10.2.2-ce.0.el7        ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ \`/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md


3、修改配置文件,使其访问地址问本机IP

[root@gitlab src]# vim /etc/gitlab/gitlab.rb 
external_url 'http://192.168.100.17'	 //找到此行并进行修改
[root@gitlab src]# gitlab-ctl reconfigure 	//重新加载配置,需要有一定的时间重新加载

4、进行汉化

[root@gitlab src]# gitlab-ctl stop //汉化前需要先关闭GitLab
ok: down: gitaly: 1s, normally up
ok: down: gitlab-monitor: 0s, normally up
ok: down: gitlab-workhorse: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 0s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: prometheus: 1s, normally up
ok: down: redis: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up
[root@gitlab src]# patch -d /opt/gitlab/embedded/service/gitlab-rails/ -p1 < /usr/local/src/10.2.2-zh.diff  //汉化补丁包我已下载到/usr/local/src/目录下
[root@gitlab src]# gitlab-ctl start //启动GitLab
ok: run: gitaly: (pid 29064) 0s
ok: run: gitlab-monitor: (pid 29072) 1s
ok: run: gitlab-workhorse: (pid 29078) 0s
ok: run: logrotate: (pid 29080) 0s
ok: run: nginx: (pid 29082) 0s
ok: run: node-exporter: (pid 29085) 0s
ok: run: postgres-exporter: (pid 29106) 0s
ok: run: postgresql: (pid 29113) 1s
ok: run: prometheus: (pid 29121) 0s
ok: run: redis: (pid 29123) 0s
ok: run: redis-exporter: (pid 29133) 1s
ok: run: sidekiq: (pid 29138) 0s
ok: run: unicorn: (pid 29146) 1s
[root@gitlab src]# gitlab-ctl reconfigure //重新加载配置

使用GitLab

1、更改GitLab的访问端口(因我这台虚拟机之前装过LNMP,而GitLab的默认web访问端口为80,所以为了避免冲突,修改一下GitLab的访问端口)

[root@gitlab src]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf 

server {
  listen *:8081; //找到此行进行修改,默认为80

2、使用浏览器访问主机IP+端口号(192.168.100.17:8081)
设置一个不少于8个字符的密码
在这里插入图片描述
使用密码登录,默认账号为root
在这里插入图片描述
创建一个项目
在这里插入图片描述
在这里插入图片描述
点击创建项目后
在这里插入图片描述
上面提示我们需要设置密钥
(1)服务器上生成ssh密钥对
在这里插入图片描述
(2)将公钥填入GitLab密钥配置。GitLab页面右上角头像–>设置–>SSH密钥
在这里插入图片描述
在这里插入图片描述
3、测试通过SSH克隆库,克隆地址为GitLab项目中的SSH链接地址(点击 “左上角的项目 - Your projects - Administrator / test-project)
在这里插入图片描述

[root@gitlab src]# git clone git@192.168.100.17:root/test-project.git
Cloning into 'test-project'...
The authenticity of host '192.168.100.17 (192.168.100.17)' can't be established.
ECDSA key fingerprint is SHA256:TF6Ncozs5ykItu5PdJsfvCopUH+mh2L+Bxxszboj5m8.
ECDSA key fingerprint is MD5:51:94:f9:7e:16:ee:5b:b9:e6:f0:5b:57:bd:91:b2:e9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.17' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.

在这里插入图片描述

GitLab账号注册与分组

1、开启邮箱注册验证
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
编辑配置文件,添加邮件配置服务

[root@gitlab src]# vim /etc/gitlab/gitlab.rb

在这里插入图片描述

[root@gitlab src]# gitlab-ctl reconfigure 	//重新架子服务

可参考官网的配置方法:https://docs.gitlab.com/omnibus/settings/smtp.html
2、创建一个组
在这里插入图片描述
在这里插入图片描述
3、添加组成员(点击左上角 “ “群组” - “test-project” - 左边的"成员" ”)
在这里插入图片描述
4、在组中创建项目(点击左上角 “ “群组” - “test-project” - 左边的"概览" - “详情” ”)
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值