#修改yum源
yum -y install wget
cd /etc/yum.repos.d
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
#安装epel源
yum -y install epel-release

#必要软件包
yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

#安装git
cd ~
wget -c -O git-src.tar.gz https://codeload.github.com/git/git/tar.gz/v2.8.1
tar -zxvf git-src.tar.gz
cd git-
make configure
./configure --prefix=/usr/local/git
make
make install
ln -fs /usr/local/git/bin/git* /usr/bin/

#添加git帐号并允许sudo
useradd --comment 'GitLab' git
echo "git ALL=(ALL)       NOPASSWD: ALL" >>/etc/sudoers

#安装Redis
yum -y install redis
service redis start

#安装ruby环境
cd ~
wget -c https://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.7.tar.gz
.tar.gz
cd ruby-
./configure --disable-install-rdoc
make && make install

ln -s /usr/local/bin/ruby /usr/bin/ruby
ln -s /usr/local/bin/gem /usr/bin/gem
ln -s /usr/local/bin/bundle /usr/bin/bundle

    #设置ruby gem源为淘宝
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
gem install bundler --no-ri --no-rdoc

#初始化GitLab库
    #登录mysql创建gitab的帐号和数据库
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

    #测试是否可以用git帐号登录数据库
    #此处需要修改/etc/sudoers,Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin 加上 :/usr/local/mysql/bin/
sudo -u git -H mysql -u gitlab -p -D gitlabhq_production

#安装GitLab
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
cd /home/git/gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

#编辑git路径, gitlab的host:port
vim config/gitlab.yml
#      bin_path: /usr/local/git/bin
#      host: localhost
#      port: 

#给文件夹添加相应的权限
chown -R git log/
chown -R git tmp/
chmod -R u+rwX  log/
chmod -R u+rwX  tmp/

#创建必要的文件夹,以及复制配置文件
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo -u git -H mkdir tmp/pids/
sudo -u git -H mkdir tmp/sockets/
sudo chmod -R u+rwX  tmp/pids/
sudo chmod -R u+rwX  tmp/sockets/
sudo -u git -H mkdir public/uploads
sudo chmod -R u+rwX  public/uploads
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

#配置数据库连接信息
sudo -u git cp config/database.yml.mysql config/database.yml
sudo -u git -H vim  config/database.yml
# production:
#      username: gitlab
#      password: "gitlab"

#安装GitLab-Shell
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v2.6.0
cd gitlab-shell/
sudo -u git -H cp config.yml.example config.yml

#编辑配置文件, 设置gitlab_url, redis-cli, log-level...
vim config.yml
#      gitlab_url: "http://localhost/"
#      /usr/bin/redis-cli

#安装git-shell
sudo -u git -H ./bin/install

#安装需要ruby的gems
cd /home/git/gitlab
sed -i "1c source https://ruby.taobao.org/" /home/git/gitlab/Gemfile
sudo -u git -H bundle install --deployment --without development test postgres aws

#初始化数据库(创建GitLab相关表)
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

#安装启动文件以及日志切割文件
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

#设置git帐号信息
sudo -u git -H git config --global user.name "caozongchao"
sudo -u git -H git config --global user.email "caozongchao@163.com"
sudo -u git -H git config --global core.autocrlf input

#更改nginx权限
chown -R git:git /usr/local/nginx
#修改nginx运行用户
sed -i "2c user git;"
            #修改php-fpm运行用户
            sed -i "149 user = git"
            sed -i "150 group = git"

#检测当前环境
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

#拉取gitlab静态资源文件
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

#启动gitlab
service gitlab start

#检测各个组件是否正常工作
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

centos 搭建gitlab的更多相关文章

  1. CentOS搭建GitLab服务器

    以下为CentOS7下安装GitLab7.4.3的全部流程 1.切换到root用户su root2.下载并安装GitLabcurl -O https://downloads-packages.s3.a ...

  2. CentOS服务器上搭建Gitlab安装步骤、中文汉化详细步骤、日常管理以及异常故障排查

    一, 服务器快速搭建gitlab方法 可以参考gitlab中文社区 的教程centos7安装gitlab:https://www.gitlab.cc/downloads/#centos7centos6 ...

  3. CentOS 7 搭建 GitLab

    概述 GitLab 是我在日常工作中使用的代码仓库管理系统,它带有非常友好的 Web 界面,并且功能丰富.下面将介绍我在 CentOS 7 上搭建 GitLab 的步骤,以及遇到的一些问题. 关于不同 ...

  4. CentOS安装gitLab服务器

    首先利用gitlab-install-el6.sh安装,比较简单: (出处:http://www.linuxidc.com/Linux/2013-06/85754.htm) 1:如果有条件,提供一台全 ...

  5. CentOS搭建Git服务器及权限管理

    声明:本教程,仅作为配置的记录,细节不展开,需要您有一点linux的命令基础,仅作为配置参考. 1. 系统环境 系统: Linux:CentOS 7.2 64位 由于CentOS已经内置了OpenSS ...

  6. Centos7使用docker搭建gitlab服务器

    了解到docker的优点,搭建快,运行要求资源低,最重要的是实现的功能和效果都能达到预期,于是决定使用docker来搭建gitlab服务器. 效果图如下: 系统环境:CentOS Linux rele ...

  7. CentOS7 搭建gitlab服务器

    本文介绍如何在CentOS7.2上搭建Gitlab服务器,并简单介绍如何使用. Preface 使用的是CentOS7.2的操作系统,安装当前最新版Gitlab服务器,下载地址:清华大学开源软件镜像站 ...

  8. 使用docker搭建gitlab服务器

    简单记录Docker的使用和GitLab的搭建 Docker基础篇 没有sudo权限 安装docker 基础命令 docker安装mysql和配置 Dockerfile常用命令 制作镜像 发布镜像 容 ...

  9. 转载:centos安装gitlab详解

    原文地址:http://blog.csdn.net/jiangtao_st/article/details/73612298 一, 服务器快速搭建gitlab方法 可以参考gitlab中文社区 的教程 ...

随机推荐

  1. OSGEARTH三维地形开源项目

    第一章   OSGEarth介绍 第二章   OSGEarth编译环境配置 OSGEarth的编译环境配置随着版本的不同.运行平台的不同,也有很大的差异.本章主要以Windows XP SP3(x86 ...

  2. nginx安装pcre

    一.有的服务器上没有安装pcre那么安装nginx的时候会报错 所以在安装之前我们可以: yum install pcre-devel 如果很不巧,服务器也没有配yum,也不能连互联网.那么我们只能自 ...

  3. python数字图像处理(8):对比度与亮度调整

    图像亮度与对比度的调整,是放在skimage包的exposure模块里面 1.gamma调整 原理:I=Ig 对原图像的像素,进行幂运算,得到新的像素值.公式中的g就是gamma值. 如果gamma& ...

  4. [CareerCup] 8.9 An In-memory File System 内存文件系统

    8.9 Explain the data structures and algorithms that you would use to design an in-memory file system ...

  5. swifter技巧(100)

    一.swift新元素 Tip1:柯里化 将方法进行柯里化,把接受多个参数的方法变换成接受第一个参数的方法,并且返回接受余下的参数,返回结果的新方法. func addTwoNumbers(a: Int ...

  6. IL指令大全

    IL是.NET框架中中间语言(Intermediate Language)的缩写.使用.NET框架提供的编译器可以直接将源程序编译为.exe或.dll文件,但此时编译出来的程序代码并不是CPU能直接执 ...

  7. 扫描函数sweep

    groot.sweep(element,vm); element 为要扫描的代码片段,vm 对应的一个 groot.view 定义的 一个Vm的整体 扫面代码 groot.sweep = functi ...

  8. VS 2010配置Qt 4.8.5

    由于早上偶然的一个念想,今天的宝贵时光就奉献给了Qt的安装及其和VS 2010的配置上了. 说实话,开始时真的查找了资料,包括博客.文库.知道等等,作者们写得都很全面,细致. 但自己动手尝试就是错误百 ...

  9. Android--手持PDA读取SD卡中文件

    近两年市场上很多Wince设备都开始转向Android操作系统,最近被迫使用Android开发PDA手持设备.主要功能是扫描登录,拣货,包装,发货几个功能.其中涉及到商品档的时候大概有700左右商品要 ...

  10. 定一个小目标:明年1024能成功转行web前端,光荣地成为一个程序员!

    第一次在博客园写博,我为什么要选择这里吗? 据说博客园这里的IT大牛如云,作为一个求知若渴的小白,我屁颠屁颠的跟着过来了. 于是今天早上兴高采烈的注册了账号,迫不及待的打开我的博客,呃!注册账号成功了 ...