CentOS搭建Gitlab的详细教程

记一次搭建gitlab服务器的经历(包括虚拟机创建及配置)

  • 前期准备

类型 软件名
服务器 CentOS7
安装文件 gitlab-ce-12.6.3-ce.0.el7.x86_64.rpm

  • 创建虚拟机

已经有linux系统的请直接略过
1.官网下载VMware,我们直接下载VMware Workstation Pro 最新版就可以了,后续激活码网上很多。
2.VMware安装CentOS7教程参考:https://www.jianshu.com/p/ce08cdbc4ddb?utm_source=tuicool&utm_medium=referral
(上面博客的CentOS7系统镜像下载链接失效了,这里提供下载链接。官网站点| |阿里站点
(最好给root多分一点内存空间(root:20GB,2G内存)。虽然可以后续再加,但是个人觉得跟重装系统一样繁琐了)
3.最后安装完成如下图:

image.png


image.png
  • 安装gitlab

提供两种安装方式 yum安装、rmp安装(个人比较喜欢第二种)
1.yum安装
这里直接参考官网安装教程

支持系统.png

安装命令.png

打开linux系统终端,首先安装gitlab必须的ssh,以及在系统防火墙中打开HTTP、HTTPS和SSH访问。

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

然后是安装发送邮件功能的postfix

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

添加gitlab的包仓库(ee改成ce)

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

安装gitlab(EXTERNAL_URL指的是你的gitlab访问地址,这里改为http://+你的linux系统ip)

sudo EXTERNAL_URL="https://gitlab.example.com" yum install -y gitlab-ce

2.自己下载rpm安装
使用官网的安装方式下载很慢(亲测网上的阿里站点,清华站点也不是很快),这里教大家直接下载rmp安装包手动安装。
首先去官网安装包仓库下载我们所需的安装包版本

image.png

下载完成之后将文件拷贝至你的linux服务器,同样需要配置ssh、防火墙、postfix,

//安装gitlab必须的ssh,以及在系统防火墙中打开HTTP、HTTPS和SSH访问。
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld
//安装发送邮件功能的postfix
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

然后cd进入你的安装包路径进行安装

rpm -ivh example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息及安装进度

出现下图即为安装成功


image.png

这种方式需要我们手动进入配置文件中修改访问地址

sudo vim /etc/gitlab/gitlab.rb

//修改文件中external_url 'http://你linux的ip'

然后浏览器上输入你的访问地址(第一次访问会让你输入新密码,用户名默认为root)


image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容