参考资料
https://github.com/mattias-ohlsson/gitlab-installer/blob/master/gitlab-install-el6.sh

环境准备
OS: CentOS 6.3 x86_64

1.初识GitLab
GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。
它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。

GitLab 要求服务器端采用 Gitolite 搭建,5.0版本以后对于ssh服务,GitLab不再使用 Gitolite ,采用自己开发的 gitlab-shell 来实现。

在GitHub上托管代码,私人项目是需要付费的,并且对于企业而言,还是将Git服务器放在内部要更加安全一些。因此,如果喜欢GitHub这种简洁风格的Git服务器,在本地搭建一个GitLab是一个非常不错的选择。
另外,如果需要对代码进行Review,推荐使用Gerrit,要复杂一些,但是功能非常强大。

2.安装部署GitLab
2.1 如果有条件,提供一台全新的Server,仅仅只安装了一些系统的软件包,可以直接使用一键安装的脚本来搭建,非常容易,具体步骤如下:

2.1.1 安装EPEL扩展源
切换到root用户
$ sudo -i
# rpm -ivh http://fr2.rpmfind.net/linux/epel/6/x86_64/epel-release-6-8.noarch.rpm

2.1.2 安装git
# yum install git

2.1.3 下载gitlab-installer.sh安装脚本
# git clone https://github.com/mattias-ohlsson/gitlab-installer.git

2.1.4 执行安装脚本
# cd gitlab-installer/
# ./gitlab-install-el6.sh

等待脚本执行完毕后,会提示如下信息(比如Server主机名为:heydevops-node-2):

### Done ########################################
#
# You have your MySQL root password in this file:
# /config/database.yml
#
# Point your browser to:
# http://heydevops-node-2 (or: http://[host-ip])
# Default admin username: admin@local.host
# Default admin password: 5iveL!fe
#
#################################################

2.1.5 将脚本的Ruby版本指向到ruby-1.9.3-p392
# vim /home/git/gitlab-shell/bin/gitlab-shell

#!/usr/local/rvm/bin/ruby-1.9.3-p392

2.1.6 使用GitLab
接着,就可以通过 http://[host-ip] ([host-ip]是Server的IP)来访问GitHub了。
首先,会看到如下所示的登陆界面:

通过上面提示信息内的账号密码登陆,登陆过后首先新增一个Project:

添加Project过后,会有一个配置向导,提供了非常详细的本地Git配置步骤:

在进行这些本地配置之前,首先要在本地生成SSH-Keygen,并将Public Key添加到GitLab中:

# ssh-keygen -t rsa
# cat .ssh/id_rsa.pub

然后将所查看到的信息,都添加到GitLab的 MyProfile - SSH Key - Add New 中:

接着,就可以再本地按照图片中所示的步骤进行操作并使用GitLab了。

2.2 上面的部署步骤,主要是采用了脚本gitlab-install-el6.sh来实现的,里面其实包含了很多的配置步骤,如果本地不是一个全新的环境,那么我们最好按照以下步骤来进行手动配置:
 
2.2.1 安装EPEL扩展源
 切换到root用户
 $ sudo -i
 
# rpm -ivh http://fr2.rpmfind.net/linux/epel/6/x86_64/epel-release-6-8.noarch.rpm
 
2.2.2 安装git
 # yum install git
 
2.2.3 安装系统依赖
 # yum -y install patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel
 
2.2.4 安装rvm
 # curl -L get.rvm.io | sudo bash -s stable
 
# source /etc/profile.d/rvm.sh
 # rvm pkg install libyaml
 # rvm --default use 1.9.3-p392
 # gem install bundler
 
2.2.5 创建git用户
 # adduser --system --create-home --comment 'GitLab' git
 
2.2.6 配置gitlab-shell(比如Server主机名为:heydevops-node-2)
 # su - git -c "git clone https://github.com/gitlabhq/gitlab-shell.git"
 # su - git -c "cp gitlab-shell/config.yml.example gitlab-shell/config.yml"
 
# su - git -c "gitlab-shell/bin/install"
 
# chmod 600 /home/git/.ssh/authorized_keys
 # chmod 700 /home/git/.ssh
 
2.2.7 安装Redis
 # yum -y install redis
 # service redis start
 # chkconfig redis on
 
2.2.8 安装配置MySQL
 # yum install -y mysql-server
 # chkconfig mysqld on
 
# echo "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" | mysql -u root
 # echo "UPDATE mysql.user SET Password=PASSWORD('gitlab') WHERE User='root'; FLUSH PRIVILEGES;" | mysql -u root
 
2.2.9 安装配置GitLab
 # su - git -c "git clone https://github.com/gitlabhq/gitlabhq.git gitlab"
 # su - git -c "cd gitlab;git checkout 5-0-stable"
 
# cd /home/git/gitlab
 # su git -c "cp config/gitlab.yml.example config/gitlab.yml"
 # sed -i "s/ host: localhost/ host: heydevops-node-2/g" config/gitlab.yml
 # sed -i "s/from: gitlab@localhost/from: gitlab@heydevops-node-2/g" config/gitlab.yml
 
2.2.10 创建Unicorn配置文件
 # su git -c "cp config/unicorn.rb.example config/unicorn.rb"
 
# sed -i "s/^listen/#listen/g" /home/git/gitlab/config/unicorn.rb
 # sed -i "s/#listen \"127.0.0.1:8080\"/listen \"127.0.0.1:3000\"/g" /home/git/gitlab/config/unicorn.rb
 
# su git -c "cp config/database.yml.mysql config/database.yml"
 # sed -i "s/secure password/gitlab/g" config/database.yml
 
# su git -c 'git config --global user.name "GitLab"'
 # su git -c 'git config --global user.email "gitlab@$GL_HOSTNAME"'
 
2.2.10 安装Gems
 # yum -y install libicu-devel
 # gem install charlock_holmes --version '0.6.9'
 
# yum -y install mysql-devel
 # su git -c "bundle install --deployment --without development test postgres"
 
# export force=yes
 # su git -c "bundle exec rake gitlab:setup RAILS_ENV=production"
 
# curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab-CentOS
 # chmod +x /etc/init.d/gitlab
 
# sed -i "17 a source /etc/profile.d/rvm.sh\nrvm use 1.9.3-p392" /etc/init.d/gitlab
 
# chkconfig gitlab on
 # service gitlab start
 
2.2.11 安装Apache
 # yum -y install httpd
 # chkconfig httpd on
 
# vim /etc/httpd/conf.d/gitlab.conf

ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
ProxyPreserveHost On

# setenforce 0
 
# service httpd start
 
2.2.12 停止iptables
 # service iptables stop
 
2.2.13 修复gitlab-shell
 # vim /home/git/gitlab-shell/bin/gitlab-shell
 将脚本的Ruby版本指向到ruby-1.9.3-p392

#!/usr/local/rvm/bin/ruby-1.9.3-p392
 
2.2.14 完成,剩下的GitLab使用步骤与2.1.6相同。

在 CentOS 上部署 GitLab (自托管的Git项目仓库)的更多相关文章

  1. CentOS 7 部署GitLab

    GitLab概述 : 是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过 Web 界面进行访问公开的戒者私人项目.Ruby on Rails 是一个可以 ...

  2. 一键部署基于GitLab的自托管Git项目仓库

    https://market.azure.cn/Vhd/Show?vhdId=9851&version=11921 产品详情 产品介绍GitLab https://about.gitlab.c ...

  3. 部署GitLab代码托管仓库

    GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,GitLab是使用Ryby开发的一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私 ...

  4. 在自己的服务器上部署 GitLab 社区版

    GitLab 简介 因为我的个人网站 restran.net 已经启用,博客园的内容已经不再更新.这篇文章是在 Gitlab 7.4 的环境下配置的,相关内容可能已经过时. 后续做了一次迁移,将 Gi ...

  5. Centos 上部署 tomcat7

     在 Centos 上部署 tomcat7 搜索tomcat,选下面红色框框的官网 选箭头指着的版本7, 选 tar.gz 格式, 下载完压缩包,使用 ftpx 工具,放在 centos 的 /opt ...

  6. CentOS上部署Django+Nginx+Uwsgi环境

    在CentOS上部署Django+Nginx+Uwsgi环境 奇谭  2016-09-01 评论  Linux  python django nginx uwsgi VirtualEnv的作用:创建隔 ...

  7. 在CentOS上部署kubernetes1.9.0集群

    原文链接: https://jimmysong.io/kubernetes-handbook/cloud-native/play-with-kubernetes.html (在CentOS上部署kub ...

  8. WTM asp.net core应用程序在Ubuntu上和CentOS上部署

    wtm在Ubuntu上和CentOS上部署 项目发布 在Visual Studio中右击Web项目,选择发布,如下图: Ubuntu安装.net core运行时 Ubuntu我是用的Vmware虚拟机 ...

  9. openshift 平台上部署 gitlab代码仓库服务

    背景: 本文档将以在openshift 平台上部署 gitlab 服务来验证集群各个服务组件的可用性以及熟悉openshift的使用方法.服务部署方式可以多种多样,灵活部署.本篇以常见的镜像部署方式来 ...

随机推荐

  1. memocached基础操作

    cmd->telnet方式链接(控制面板-启动该功能)telenet +ip +(端口号) memcahed 只有 string类型的 整个数据全部都是存在内存里面的 连接数 内存的大小 失效时 ...

  2. adb之mokey的用法

    monkey是安卓稳定性的测试方向 目录 1.使用格式 2.一般命令 3.分析monkey日志 1.使用格式 monkey的固定使用模式如下:[adb shell] monkey [options] ...

  3. UI自动化之特殊处理一(iframe\句柄\鼠标键盘)

    iframe\句柄\鼠标键盘是一些比较特殊的事件,需要特殊处理 目录 1.iframe 2.句柄(handle) 3.鼠标键盘 1.iframe iframe 是内嵌的网页元素,也可以说是内嵌的框架, ...

  4. 5 centos 6.10 三节点安装apache hadoop 2.9.1

    Hadoop 版本: apache hadoop 2.9.1JDK 版本: Oracle JDK1.8集群规划master(1): NN, RM, DN, NM, JHSslave1(2): DN, ...

  5. if you don't go after what you want, you'll never have it

    conquest.n. 征服 quantitative: adj. 数量的 cellar: n. 地窖 roast. v. 烧烤 allowance. n. 津贴 drainage. n. 排水 ma ...

  6. [Web 前端] 007 css 常见的七种选择器

    1. 标签选择器 影响范围大 建议尽量应用在层级选择器中 举例 <!-- body 体中的 div --> <div>box...</div> /* style 中 ...

  7. css定位:相对定位、绝对定位、固定定位的区别与特性

    css定位:相对定位.绝对定位.固定定位的区别与特性 原文地址:http://www.qingzhouquanzi.com/106.html css定位常用的有以下三种: 使用了定位的共同特性: 这三 ...

  8. idea / eclipse 批量 替换 空白行

    1.选择Regular expression项,允许查询匹配正则表达式 2.在Find文本框输入正则表达式:^\s*\n   , 点击ReplaceAll 转移字符 含义 ^ 否 * 0个或多个 \s ...

  9. loading 加载工具

    loading 加载工具:http://loading.awesomes.cn/

  10. ARM汇编3

    一. 什么是协处理器? 1.1. SoC内部另一处理核心,协助主CPU实现某些功能,被主CPU调用执行一定任务. 1.2. ARM设计上支持多达16个协处理器,但是一般SoC只实现其中的CP15.(c ...