在CentOS系统上安装所需的依赖:
ssh,
防火墙,
postfix(用于邮件通知) ,
wget,
以下命令也会打开系统防火墙中的HTTP和SSH端口访问
使用命令
yum install -y curl policycoreutils-python openssh-server
安装完成之后,需要启用和启动sshd服务,执行命令:
systemctl enable sshd
systemctl start sshd
打开 /etc/sysctl.conf 文件,在文件最后添加新的一行
输入如下文本:
net.ipv4.ip_forward = 1
这样,就配置好了防火墙。
作用为,当linux主机有多个网卡时,一个网卡收到的信息时可以传递给其他网卡,即数据可以进行转发
systemctl enable firewalld
systemctl start firewalld
systemctl enable firewalld
由于gitlab是需要使用postfix来作为邮件发送服务的,还需安装下以下服务。
直接命令安装,确认安装环节,输入【y】即可:
yum install postfix
安装完成之后,打开/etc/postfix/main.cf 文件,找到inet_protocols = all,将 all 改为 ipv4。
然后,启动postfix,输入命令:
systemctl enable postfix
systemctl start postfix
安装gitlab
到了开始安装gitlab的时刻了
首先,先更改下镜像源地址(该镜像源的地址设置成了清华大学的,下载提速)
在/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 makecache
![](
然后,我们就可以正式安装gitlab了,执行如下命令:
yum install -y gitlab-ce
运行gitlab首先,我们需要配置一下GitLab的域名,非必须的,但建议配置一下,便于访问gitlab的时,方面记忆。
打开/etc/gitlab/gitlab.rb文件,找到external_url 这个选项,改成机器ip或者域名,如图:
接下来,初始化gitlab,
输入命令:
gitlab-ctl reconfigure
当出现如图的画面时,即为初始化配置完成
用root账号登录,密码在这里查看,只保留24小时
启动gitlab
sudo gitlab-ctl start
启动后,发现页面无法访问
输入命令systemctl status firewalld发现防火墙在运行着
输入命令service firewalld stop关闭防火墙即可成功访问,访问名称就是http://你设置的ip(不需要加端口)
先修改完密码(要不设置语言不生效)
然后设置语言为中文
退出登录后,重新登录语言即为中文
常用命令总结:
初始化gitlab:sudo gitlab-ctl reconfigure
关闭gitlab:sudo gitlab-ctl stop
启动gitlab:
sudo gitlab-ctl start
#systemctl stop firewalld //关闭防火墙
#systemctl disable firewalld //禁用防火墙开机启动
//启动邮件服务,并开机加载
#systemctl start postfix
#systemctl enable postfix