{{ v.name }}
{{ v.cls }}类
{{ v.price }} ¥{{ v.price }}
任务时间:5min~10min
在正式开始安装之前,先更新软件包并打开相关服务的权限。
yumupdate-y安装sshd
安装sshd:
yuminstall-ycurlpolicycoreutils-pythonopenssh-server
启用并启动sshd:
systemctlenablesshdsystemctlstartsshd配置防火墙
打开/etc/sysctl.conf文件,在文件最后添加新的一行并按ctrl+s保存:
net.ipv4.ip_forward=1
启用并启动防火墙:
systemctlenablefirewalldsystemctlstartfirewalld
放通http:
firewall-cmd--permanent--add-service=http
重启防火墙:
systemctlreloadfirewalld
在实际使用中,可以使用systemctlstatusfirewalld命令查看防火墙的状态。
gitlab需要使用postfix来发送邮件。当然,也可以使用smtp服务器,具体步骤请参考官方教程。
安装:
yuminstall-ypostfix
打开/etc/postfix/main.cf文件,在第119行附近找到inet_protocols=all,将all改为ipv4并按ctrl+s保存:
inet_protocols=ipv4
启用并启动postfix:
systemctlenablepostfixsystemctlstartpostfix配置swap交换分区
由于gitlab较为消耗资源,我们需要先创建交换分区,以降低物理内存的压力。在实际生产环境中,如果服务器配置够高,则不必配置交换分区。
新建2gb大小的交换分区:
ddif=/dev/zeroof=/root/swapfilebs=1mcount=2048
格式化为交换分区文件并启用:
mkswap/root/swapfileswapon/root/swapfile
添加自启用。打开/etc/fstab文件,在文件最后添加新的一行并按ctrl+s保存:
/root/swapfileswapswapdefaults00安装gitlab
任务时间:10min~15min
由于网络环境的原因,将repo源修改为[清华大学]。
在/etc/yum.repos.d目录下新建gitlab-ce.repo文件并保存。内容如下:
示例代码:/etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]name=gitlabcerepositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/
刚才修改过了yum源,因此先重新生成缓存:(此步骤执行时间较长,一般需要3~5分钟左右,请耐心等待)
yummakecache
安装gitlab:(此步骤执行时间较长,一般需要3~5分钟左右,请耐心等待)
yuminstall-ygitlab-ce初始化gitlab
任务时间:10min~15min
打开/etc/gitlab/gitlab.rb文件,在第13行附近找到external_url'http://gitlab.example.com',将单引号中的内容改为自己的域名(带上协议头,末尾无斜杠),并按ctrl+s保存。
例如:
external_url'http://work.myteam.com'
记得将域名通过a记录解析到<您的cvmip地址>哦。
特别重要!
使用如下命令初始化gitlab:(此步骤执行时间较长,一般需要5~10分钟左右,请耐心等待)
sudogitlab-ctlreconfiguregitlab安装已完成
任务时间:时间未知
至此,我们已经成功地在centos7上搭建了gitlab。现在可以在这里(http://<您的cvmip地址>/)访问gitlab了。