一、安装配置必要的依赖

1、安装ssh

  1. sudo yum install -y curl policycoreutils-pythonopenssh-server

2、ssh设置开机启动

  1. sudo systemctl enable sshd

3、启动ssh

  1. sudo systemctl start sshd

4、添加http服务到firewalld,pemmanent表示永久生效,若不加—permanent系统下次启动后就会失效

  1. sudo firewall-cmd --permanent --add-service=http

5、如果没有安装防火墙,则安装

  1. sudo yum install firewalld systemd -y

6、开启防火墙

  1. service firewalld start

7、重启防火墙

  1. sudo systemctl reload firewalld

8、接下来安装postfix以发送通知电子邮件。如果要使用其他解决方案发送电子邮件,请跳过此步骤,并在安装Gitlab后配置外部SMTP服务器

  1. sudo yum install postfix

9、设置postfix开机启动

  1. sudo systemctl enable postfix

10、启动postfix

  1. sudo systemctl start postfix

如果出现以下提示
20190707101357458.png修改 /etc/postfix/main.cf的设置inet_protocols = ipv4和inet_interfaces = all

  1. sudo vim /etc/postfix/main.cf

20190707101603246.png

二、添加Gitlab包存储库并安装包

1、安装wget(已安装请跳过)

  1. sudo yum install wget

2、安装vim(已安装请跳过)

  1. sudo yum -y install vim*

3、添加gitlab镜像

  1. wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.5.7-ce.0.el7.x86_64.rpm

4、镜像配置

新建 /etc/yum.repos.d/gitlab-ce.repo

  1. sudo vim /etc/yum.repos.d/gitlab-ce.repo

按’i’键进入编辑状态,编辑内容为

  1. [gitlab-ce]
  2. name=Gitlab CE Repository
  3. baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
  4. gpgcheck=0
  5. enabled=1

输入完内容后按’ESC’,然后输入’:wq!’强制保存退出

5、安装gitlab

  1. sudo yum makecache
  2. sudo yum install gitlab-ce

安装过程会需要一些时间,如果出现如下图所示logo,则表示Gitlab安装成功
微信图片_20190806134540.png

6、修改gitlab配置文件指定服务器ip和自定义端口

  1. sudo vim /etc/gitlab/gitlab.rb

进入编辑器后按’i’键,编辑内容为
TIM图片20190806134900.png
输入完内容后按’ESC’,然后输入’:wq!’强制保存退出

7、将9090端口添加到防火墙中

  1. sudo firewall-cmd --zone=public --add-port=9090/tcp --permanent

8、重启防火墙

  1. sudo systemctl reload firewalld

9、重置gitlab

  1. gitlab-ctl reconfigure

重置过程会需要一段时间

10、启动gitlab

  1. gitlab-ctl restart

11、访问Gitlab页面

在浏览器中输入第六步配置的服务器ip和端口号

12、注册账号密码然后登录即可

参考

https://blog.csdn.net/u010375456/article/details/94965423
https://www.cnblogs.com/dotnet261010/p/9811161.html
https://mirrors.tuna.tsinghua.edu.cn/help/gitlab-ce/