git学习之gitLab搭建

GitLab是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。

1.准备环境

需要的依赖:ssh,firewalld, posfix

  1. 更新软件包
    yum update -y
  2. 安装sshd (如上:已经安装sshd,不用在安装)
    ①查看是否安装sshd
    [root@izwz9a2wkun9zd9b60koopz ~]# systemctl status sshd
    ● sshd.service - OpenSSH server daemon
       Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
       Active: active (running) since Wed 2019-05-22 09:54:31 CST; 7min ago
         Docs: man:sshd(8)
               man:sshd_config(5)
     Main PID: 29113 (sshd)
       CGroup: /system.slice/sshd.service
               └─29113 /usr/sbin/sshd -D
    
    May 22 09:54:31 izwz9a2wkun9zd9b60koopz sshd[29113]: Server listening on 0.0.0.0 port 22.
    May 22 09:54:31 izwz9a2wkun9zd9b60koopz systemd[1]: Stopped OpenSSH server daemon.
    May 22 09:54:31 izwz9a2wkun9zd9b60koopz systemd[1]: Starting OpenSSH server daemon...
    May 22 09:54:31 izwz9a2wkun9zd9b60koopz systemd[1]: Started OpenSSH server daemon.
    
    安装并启动
    yum install -y curl policycoreutils-python openssh-server
    systemctl enable sshd
    systemctl start sshd
  3. 安装 postfix
    GitLab 需要使用 postfix 来发送邮件
    yum install -y postfix
    打开 /etc/postfix/main.cf 文件,在第 119 行附近找到 inet_protocols = all,将 all 改为 ipv4
    inet_protocols = ipv4
    启用并启动
    systemctl enable postfix 
    systemctl start postfix
    
  4. 配置swap交换分区
    free -h查看可用内存
    由于GitLab较为消耗资源,我们需要先创建交换分区,以降低物理内存的压力,如果可以内存大于4GB,可以不必配置交换分区
    ①新建2GB大小的交换分区
    dd if=/dev/zero of=/root/swapfile bs=1M count=2048
    ②格式化为交换分区文件并启用
    mkswap /root/swapfile
    swapon /root/swapfile
    ③添加自启用。打开 /etc/fstab 文件,在文件最后添加新的一行
    /root/swapfile swap swap defaults 0 0

2.安装GiltLab

  1. 将软件源修改为国内源

    由于网路原因,将repo源修改为https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/

    /etc/yum.repos.d目录下新建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
    

    重新生成yum缓存
    yum makecache

  2. 安装GitLab
    yum install -y gitlab-ce

  3. 配置GitLab
    打开 /etc/gitlab/gitlab.rb 文件,在第 13 行附近找到 external_url ‘http://gitlab.example.com’,将单引号中的内容改为自己的域名(带上协议头,末尾无斜杠),或者改为ip加端口
    external_url 'http://work.myteam.com'
    初始化 GitLab
    gitlab-ctl reconfigure

安装完成,可以访问 gitlab

日常管理
gitlab-ctl start|stop|status|restart

3.GiltLab汉化

  1. 查看gitlab版本

    [root@izwz9a2wkun9zd9b60koopz ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 
      11.10.4
    
  2. 下载中文补丁
    注意补丁包版本一定要与gitlab版本一致
    wget https://gitlab.com/xhang/gitlab/-/archive/v11.10.4-zh/gitlab-v11.10.4-zh.tar.gz

  3. 解压
    tar -zxvf gitlab-v11.10.4-zh.tar.gz

  4. 复制并覆盖
    cp -rf gitlab-v11.10.4-zh/* /opt/gitlab/embedded/service/gitlab-rails/

    注意使用cp 命令时,即使加了-rf也会有覆盖提示,
    这是由于cp被系统设置了别名,相当于cp=‘cp -i’

    [root@izwz9a2wkun9zd9b60koopz ~]# alias
    alias cp='cp -i'
    alias egrep='egrep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias grep='grep --color=auto'
    alias l.='ls -d .* --color=auto'
    alias ll='ls -l --color=auto'
    alias ls='ls --color=auto'
    alias mv='mv -i'
    alias rm='rm -i'
    alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
    

    有两种方式解决

    1. 使用原生的cp命令/bin/cp -rf xxxx
    2. 取消cp命令别名unalias cp 复制完成之后恢复别名:alias cp='cp -i'

    别名配置文件在.bashrc/etc/bashrc

  5. 重新配置,启动gitlab
    gitlab-ctl reconfigure
    gitlab-ctl restart

    汉化完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值