GitLab是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
需要的依赖:ssh,firewalld, posfix
更新软件包 yum update -y安装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安装 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 配置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将软件源修改为国内源
由于网路原因,将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
安装GitLab yum install -y gitlab-ce
配置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
查看gitlab版本
[root@izwz9a2wkun9zd9b60koopz ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 11.10.4下载中文补丁 注意补丁包版本一定要与gitlab版本一致 wget https://gitlab.com/xhang/gitlab/-/archive/v11.10.4-zh/gitlab-v11.10.4-zh.tar.gz
解压 tar -zxvf gitlab-v11.10.4-zh.tar.gz
复制并覆盖 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'有两种方式解决
使用原生的cp命令/bin/cp -rf xxxx取消cp命令别名unalias cp 复制完成之后恢复别名:alias cp='cp -i'别名配置文件在.bashrc和/etc/bashrc
重新配置,启动gitlab gitlab-ctl reconfigure gitlab-ctl restart
汉化完成