说明:本文基于 原文链接 进行整理

环境

  1. 阿里云主机
  2. centos 7.6 x86_64
  3. 2核cpu/4g内存

搭建步骤

  1. 修改yum源为阿里云源:

    1. sudo yum install -y curl wget
    2. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    3. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    4. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    5. yum clean all
    6. yum makecache
  2. 安装依赖:sudo yum install -y policycoreutils-python openssh-server
  3. ssh开机自启:sudo systemctl enable sshd
  4. ssh启动:sudo systemctl start sshd
  5. postfix安装:sudo yum install -y postfix
  6. postfix开机自启:sudo systemctl enable postfix
  7. 修改postfix配置:vim /etc/postfix/main.cf 找到,inet_interfaces = localhost,将其改为inet_interfaces = all:wq保存退出,
  8. postfix启动:sudo systemctl start postfix
  9. 添加gitlab包仓库:curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
  10. 安装gitlab:sudo EXTERNAL_URL="你Gitlab服务器运行所在的公网IP地址" yum install -y gitlab-ce
  11. 检查gitlab运行状态:gitlab-ctl status,看是否所有服务都正常运行的
  12. 访问gitlab地址:http://你Gitlab服务器运行所在的公网IP地址,即可出现gitlab界面,如图:
    gitlab界面

备注

  1. centos 7 才支持 systemctl命令
  2. 1核cpu+2g内存的服务器带不动gitlab,在安装时会报允许分配的内存不足
  3. gitlab常用:

    1. 查看状态:gitlab-ctl status
    2. 查看日志:gitlab-ctl tail
    3. 配置文件:/etc/gitlab/gitlab.rb
    4. 安装目录:/opt/gitlab
    5. 日志目录:/var/log/gitlab
    6. gitlab包安装自带的服务:nginx/redis/postgres/ruby on rails/unicorn

参考链接

  1. gitlab搭建原文链接
  2. postfix装好但是收不到邮件解决方法
  3. gitlab迁移

xieguanping12
17 声望1 粉丝

坚持写好每一个bug!