`

在CentOS上安装Gitlab

 
阅读更多

因为涉及的依赖多,所以新手在安装Gitlab时往往遇到不少障碍。如果按照下面的方法,则可以轻松装好Gitlab.

第一步:复制脚本并执行

#!/bin/bash
unknown_os ()
{
  echo "Unfortunately, your operating system distribution and version are not supported by this script."
  echo
  echo "You can override the OS detection by setting os= and dist= prior to running this script."
  echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
  echo
  echo "For example, to force CentOS 6: os=el dist=6 ./script.sh"
  echo
  echo "Please email support@packagecloud.io and let us know if you run into any issues."
  exit 1
}

curl_check ()
{
  echo "Checking for curl..."
  if command -v curl > /dev/null; then
    echo "Detected curl..."
  else
    echo "Installing curl..."
    yum install -d0 -e0 -y curl
  fi
}

detect_os ()
{
    if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
    if [ -e /etc/os-release ]; then
      . /etc/os-release
      dist=`echo ${VERSION_ID} | awk -F '.' '{ print $1 }'`
      os=${ID}

    elif [ `which lsb_release 2>/dev/null` ]; then
      # get major version (e.g. '5' or '6')
      dist=`lsb_release -r | cut -f2 | awk -F '.' '{ print $1 }'`      # get os (e.g. 'centos', 'redhatenterpriseserver', etc)
      os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`

    elif [ -e /etc/oracle-release ]; then
      dist=`cut -f5 --delimiter=' ' /etc/oracle-release | awk -F '.' '{ print $1 }'`
      os='ol'

    elif [ -e /etc/fedora-release ]; then
      dist=`cut -f3 --delimiter=' ' /etc/fedora-release`
      os='fedora'

    elif [ -e /etc/redhat-release ]; then
      os_hint=`cat /etc/redhat-release  | awk '{ print tolower($1) }'`
      if [ "${os_hint}" = "centos" ]; then
        dist=`cat /etc/redhat-release | awk '{ print $3 }' | awk -F '.' '{ print $1 }'`
        os='centos'
      elif [ "${os_hint}" = "scientific" ]; then
        dist=`cat /etc/redhat-release | awk '{ print $4 }' | awk -F '.' '{ print $1 }'`
        os='scientific'
      else
        dist=`cat /etc/redhat-release  | awk '{ print tolower($7) }' | cut -f1 --delimiter='.'`
        os='redhatenterpriseserver'
      fi

    else
      aws=`grep -q Amazon /etc/issue`
      if [ "$?" = "0" ]; then
        dist='6'
        os='aws'
      else
        unknown_os
      fi
    fi
  fi

  if [[ ( -z "${os}" ) || ( -z "${dist}" ) || ( "${os}" = "opensuse" ) ]]; then
    unknown_os
  fi

  # remove whitespace from OS and dist name
  os="${os// /}"
  dist="${dist// /}"

  echo "Detected operating system as ${os}/${dist}."
}

main ()
{
  detect_os
  curl_check

  yum_repo_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=${os}&dist=${dist}&source=script"

  yum_repo_path=/etc/yum.repos.d/gitlab_gitlab-ce.repo
  echo "Downloading repository file: ${yum_repo_config_url}"

  curl -sSf "${yum_repo_config_url}" > $yum_repo_path
  curl_exit_code=$?
  if [ "$curl_exit_code" = "22" ]; then
    echo
    echo
    echo -n "Unable to download repo config from: "
    echo "${yum_repo_config_url}"
    echo
    echo "This usually happens if your operating system is not supported by "
    echo "packagecloud.io, or this script's OS detection failed."
    echo
    echo "You can override the OS detection by setting os= and dist= prior to running this script."
    echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
    echo
    echo "For example, to force CentOS 6: os=el dist=6 ./script.sh"
    echo
    echo "If you are running a supported OS, please email support@packagecloud.io and report this."
    [ -e $yum_repo_path ] && rm $yum_repo_path
    exit 1
  elif [ "$curl_exit_code" = "35" ]; then
    echo
    echo "curl is unable to connect to packagecloud.io over TLS when running: "
    echo "    curl ${yum_repo_config_url}"
    echo
    echo "This is usually due to one of two things:"
    echo
    echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
    echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
    echo
    echo "Contact support@packagecloud.io with information about your system for help."
    [ -e $yum_repo_path ] && rm $yum_repo_path
    exit 1
  elif [ "$curl_exit_code" -gt "0" ]; then
    echo
    echo "Unable to run: "
    echo "    curl ${yum_repo_config_url}"
    echo
    echo "Double check your curl installation and try again."
    [ -e $yum_repo_path ] && rm $yum_repo_path
    exit 1
  else
    echo "done."
  fi

  echo "Installing pygpgme to verify GPG signatures..."
  yum install -y pygpgme --disablerepo='gitlab_gitlab-ce'
  pypgpme_check=`rpm -qa | grep -qw pygpgme`
  if [ "$?" != "0" ]; then
    echo
    echo "WARNING: "
    echo "The pygpgme package could not be installed. This means GPG verification is not possible for any RPM installed on your system. "
    echo "To fix this, add a repository with pygpgme. Usualy, the EPEL repository for your system will have this. "
    echo "More information: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F"
    echo

    # set the repo_gpgcheck option to 0
    sed -i'' 's/repo_gpgcheck=1/repo_gpgcheck=0/' /etc/yum.repos.d/gitlab_gitlab-ce.repo
  fi

  echo "Installing yum-utils..."
  yum install -y yum-utils --disablerepo='gitlab_gitlab-ce'
  yum_utils_check=`rpm -qa | grep -qw yum-utils`
  if [ "$?" != "0" ]; then
    echo
    echo "WARNING: "
    echo "The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features."
    echo
  fi

  echo "Generating yum cache for gitlab_gitlab-ce..."
  yum -q makecache -y --disablerepo='*' --enablerepo='gitlab_gitlab-ce'

  echo
  echo "The repository is setup! You can now install packages."
}

main

 

第二步:

执行成功后,检查是否可以通过yum search 最新的gitlab包:

yum search gitlab

如果可以,直接yum install -y gitlab-ce

 

第三步:

安装完成后,进行配置:

cd /opt/gitlab/bin

./gitlab-ctl reconfigure

 

第四步:

配置完成后就可以启动了:

cd /opt/gitlab/bin/

./gitlab-ctl start

访问:http://ip

注意8080端口要用

分享到:
评论

相关推荐

    Centos7安装Gitlab

    在安装 Gitlab 之前,我们需要准备 Centos7 环境,并关闭防火墙。然后,我们可以安装 Gitlab 需要的组件,例如 curl、policycoreutils、openssh-server、openssh-clients 和 postfix。然后,我们可以下载 Gitlab ...

    centos7安装gitlab

    centos7安装gitlab

    centos安装GITLAB

    在CentOS上安装GitLab的过程中,可能会遇到一个与Ruby版本相关的错误:“EC_GROUP_new_curve_GF2m”。这个错误通常出现在尝试安装Ruby 1.9.3-p0时,由于其与OpenSSL库的兼容性问题导致。Ruby是GitLab运行所必需的...

    centos gitlab-runner 13.8.x rpm 离线安装包

    centos gitlab-runner 13.8.x rpm 离线安装包

    centos7.5安装gitlab和gitlab备份迁移恢复.docx

    在安装完成后,需要编辑 GitLab 的配置文件 `/etc/gitlab/gitlab.rb`,将 `external_url` 配置为自己的服务器 IP 和端口号: ``` vim /etc/gitlab/gitlab.rb external_url http://IP:端口 ``` 然后,需要执行配置...

    centos7安装部署gitlab服务器

    根据给定的信息,本文将详细解释如何在CentOS 7上安装和配置GitLab服务器,具体包括以下几个步骤:安装依赖软件、设置Postfix为GitLab提供邮件服务、下载并安装GitLab安装包以及最终的GitLab配置。 ### 一、安装...

    CentOS 7 安装gitlab-ce-11及邮件配置

    CentOS 7 下安装 Gitlab-CE-11及邮件配置,安装步骤和邮件配置参数

    阿里云服务器CentOS7.2安装配置gitlab

    本文档旨在指导用户如何在阿里云服务器上安装并配置GitLab。GitLab是一款开源的Git仓库管理工具,它提供了非常丰富的特性,如版本控制、项目管理、CI/CD等,适合团队协作开发。本文档假设读者已经具备基本的Linux...

    Linux(centos7)安装Gitlab

    - 在安装完成后,使用 `gitlab-ctl` 命令来进行基本配置: ```bash gitlab-ctl reconfigure ``` 此命令会重新配置 GitLab 的各种组件,包括 PostgreSQL 数据库、Redis 缓存系统等。 - 查看 GitLab 服务的状态: ...

    Centos7 源码安装Gitlab.md

    Centos7 源码安装Gitlab.md 存放这里,让大家下载快捷一点

    CentOS7下GitLab跨大版本升级的方法

    在安装完成后,需要根据新版本的要求进行必要的配置调整,例如更新配置文件`/etc/gitlab/gitlab.rb`,并执行`sudo gitlab-ctl reconfigure`使配置生效。 升级过程中可能会遇到数据库不兼容的情况,此时GitLab会自动...

    centos6搭建gitlab的方法步骤

    本文将详细介绍如何在 CentOS 6 上搭建一个完整的 GitLab 服务。 #### 环境准备 在开始安装之前,请确保服务器已更新到最新状态: ```bash yum -y update ``` #### 基础环境安装 首先需要安装 Git、Redis、Ruby ...

    centos7-gitlab:仅一些脚本可帮助在CentOS 7上安装GitLab

    在CentOS 7上进行完整安装生活在任何平台上的Docker容器您需要了解一些先决条件: 您将需要已安装mysql或mariadb并对其进行配置以进行网络访问您将需要以具有sudo访问权限(最好是sudo NOPASSWD访问权限)的用户...

    CentOS8.1搭建Gitlab服务器详细教程

    虽然主页上可能更多地推广旗舰版,但在“Install GitLab”部分可以找到安装说明。官方推荐至少4GB的内存来运行GitLab,但为了保证系统稳定性,建议分配6GB或更多。在CentOS 8的安装指南中,需要仔细寻找社区版的入口...

    jenkins+gitlab+centos7+windows自动化环境搭建

    在CentOS上,你可以通过Yum安装GitLab社区版。安装完成后,配置GitLab的URL以供Jenkins使用。 **Jenkins与GitLab集成** 为了实现GitLab推送到Jenkins的自动构建,你需要在GitLab项目中配置Web Hook,指向Jenkins的...

    【Gitlab CI】CentOS 7 使用 gitlab-runner 实现 Vue 项目自动化构建

    Gitlab 在 8.0 后默认集成 CI 功能,相比 Hook 来说可以说是更加简单一些,可以省去在服务器自行书写 ...不会操作请参见 Gitlab 上的官方教程 安装 gitlab-runner 这里有两种选择,通过 rpm 包安装或通过 docker 安装

    centos7平台集成Jenkins+gitlab

    在开始安装 Jenkins 和 GitLab 之前,需要先安装 JDK。使用以下命令安装 JDK: yum -y list java* 安装完成后,使用以下命令测试 JDK 是否安装成功: java -version 二、Jenkins 安装 安装 Jenkins 需要先添加 ...

Global site tag (gtag.js) - Google Analytics