一,安装环境

OS:redhat7.4

二,安装依赖包

yum -y groupinstall 'Development Tools'  ===>待验证

yum -y install python-docutils

yum -y install readline readline-devel ncurses-devel gdbm-devel  glibc-devel tcl-devel openssl-devel expat-devel  byacc sqlite-devel

yum -y install libyaml libyaml-devel  libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui crontabs  logwatch logrotate git cmake libcom_err-devel.i686 libcom_err-devel.x86_64 

yum -y install postfix

检查git 版本:git --version  如果不是2.9.0 重装git

/*****************************git 2.9.0安装************************/

git依赖包:

yum -y install zlib-devel perl-CPAN gettext curl-devel(rhel7下名字为libcurl-devel) expat-devel gettext-devel openssl-devel

git下载&安装

mkdir /tmp/git && cd /tmp/git

wget https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz

tar xvf git-2.9.0.tar.gz

cd git-2.9.0/

./configure --prefix=/usr/local

make  prefix=/usr/local all

make prefix=/usr/local install

退出当前shell窗口,重新进入检查git版本

三,安装ruby

mkdir /tmp/ruby && cd  /tmp/ruby

wget https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p237.tar.gz  ====》没有的话,就是用p327版本

tar zxvf ruby-1.9.3-p237.tar.gz

cd ruby-1.9.3-p237/

./configure

vim ext/openssl/ossl_pkey_ec.c 修改内容如下:

make

make prefix=/usr/local install

检查ruby版本:ruby --version

四,安装bundler

gem list 检查当前是否安装了bundler

若安装了其他版本则卸载 gem uninstall bundler --version=xxx

安装bundler  1.3.5 版本:

gem install bundler --version=1.3.5

五,设置用户

adduser --system --shell /bin/bash --comment 'gitlab' --create-home --home-dir /home/git git

adduser --create-home --home-dir /home/gitlab gitlab

usermod -a -G git gitlab

passwd git  ===>123456

passwd gitlab ===>123456

验证信息:

id git

id gitlab

生产gitlab密钥:

sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa

注意:id_rsa  id_rsa.pub权限要为600

六,gitolite

cd /home/git

sudo -u git -H git clone -b gl-v320 https://github.com/gitlabhq/gitolite.git /home/git/gitolite

/***********************设置gitlab作为gitolite的管理员:*********************/

sudo -u git -H mkdir /home/git/bin
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/bin" "export PATH" >> /home/git/.profile'
 sudo -u git -H sh -c 'gitolite/install -to /home/git/bin'

sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
 sudo chmod 0444 /home/git/gitlab.pub

sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"

=====》如果报指纹无法识别验证:

解决方案:ssh-keygen -l -f gitlab.pub    查看:前两位和后两位的是数字还是字母,注意大小写

vim /home/git/bin/triggers/post-compile/ssh-authkeys

修改:fp_file函数下的  _die "fingerprinting failed for '$f'" unless $fp =~ /([0-9a-f][0-9a-f](:[0-9a-fA-Z][0-9a-fA-Z])+)/;

后面的正则匹配你查看的冒号前后各2位

注意:/home/git/.ssh/authorized_keys权限为600

sudo chmod 750 /home/git/.gitolite/
 sudo chown -R git:git /home/git/.gitolite/
sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/
 sudo chown -R git:git /home/git/repositories/

echo "Host localhost
           StrictHostKeyChecking no
           UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config

echo "Host 主机名
           StrictHostKeyChecking no
           UserKnownHostsFile=/dev/null" | sudo tee -a /etc/ssh/ssh_config

cat /etc/hosts   里面的主机名对应的IP,不是localhost

验证配置正常:

sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin

####################################ssh 免密登陆失败的话

cat /var/log/secure 查看sshd相关日志  ====》 .ssh所在的家目录不允许组有W权限 chmod 750 /home/git

####################################实在解决不了执行下面步骤

如果这一步出错,需要重新配置ssh密钥,并且删除git下的隐藏目录如.logout .bundle .gitolite .gnome 有就删

sudo rm -rf /tmp/gitolite-admin

七,数据库

安装MySQL数据库,yum或tar包安装都可以

登陆mysql,操作如下:

mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '123456';

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';

mysql>flush privileges;

mysql>quit;

八,Gitlab

cd /home/gitlab

sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab

cd /home/gitlab/gitlab

sudo -u gitlab -H git checkout 4-0-stable

sudo -u gitlab -H cp config/gitlab.yml.example config/gitlab.yml

sudo -u gitlab -H vim config/gitlab.yml

修改内容如下:

sudo chown -R gitlab log/
sudo chown -R gitlab tmp/
 sudo chmod -R u+rwX  log/
 sudo chmod -R u+rwX  tmp/
 sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb

sudo -u gitlab cp config/database.yml.mysql config/database.yml

sudo -u gitlab vim config/database.yml

修改内容如下:

安装gem

sudo gem install charlock_holmes --version '0.6.9'

初始化数据库

vim Gemfile   和Gemfile.lock

修改modernizr为modernizr_rails

版本 2.6.2 改为2.6.2.1

sudo -u gitlab -H bundle install --deployment --without development test postgres

sudo -u gitlab -H git config --global user.name "GitLab"
sudo -u gitlab -H git config --global user.email "gitlab@localhost"

sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive

/********************安装redis*************************/

/*******************************************************/

启动redis

/usr/local/bin/redis-server

初始化database&开启高级功能

sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production

sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/4-0-stable/init.d/gitlab -P /etc/init.d/

sudo chmod +x /etc/init.d/gitlab

检查app状态:

sudo -u gitlab -H bundle exec rake gitlab:env:info RAILS_ENV=production

如果出现gitolite version 看不见:

解决方案:cd /home/git && gitolite/install && cd gitolite/src && chown git:git VERSION

或者是权限的问题 /home/git目录权限应为770 下边的gitolite   src都应该是770

sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production

启动gitlab :service gitlab start

再次检查 sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production

九,安装nginx

yum install nginx

sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/4-0-stable/nginx/gitlab -P /etc/nginx/sites-available/

cd /etc/nginx/sites-available

ln -s /etc/nginx/sites-available/gitlab //etc/nginx/conf.d/gitlab.conf

(1)vim /etc/nginx/conf.d/gitlab.conf

修改内容如下:

vim /etc/nginx/nginx.conf

修改内容如下:

usermod -a -G git nginx

(2) 或者直接修改nginx.conf如下:(推荐)

user  root git;
worker_processes  2;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
    #tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

upstream gitlab {
  server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket;
}
server {
  listen 10.2.177.44:80;         # e.g., listen 192.168.1.1:80;
  server_name bogon;     # e.g., server_name source.example.com;
  root /home/gitlab/gitlab/public;
  server_tokens off;
  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
  client_max_body_size 5m;
  location / {
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below
    try_files $uri $uri/index.html $uri.html @gitlab;
  }

# if a file, which is not found in the root folder is requested,
  # then the proxy pass the request to the upsteam (gitlab unicorn)
  location @gitlab {
    proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    proxy_redirect     off;

proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              10.2.177.44;
    proxy_set_header   X-Real-IP         $remote_addr;

proxy_pass http://gitlab;
  }

}
#    include /etc/nginx/conf.d/*.conf;
}

如果启动报错:页面出现500   log/production出现

解决方案:检查版本信息:

1)bundler (1.3.5)   /charlock_holmes (0.6.9)/rdoc (3.9.4)/rake(0.9.2.2)/json(1.5.4) /minitest(2.5.1)/io-console(0.3)/bigdecimal(1.1.0)

检查发现ruby版本是2.0  重装1.9.3-p237 其他版本不变

gem uninstall bundler --version=1.17.1

gem install bundler --version=1.3.5

gem install charlock_holmes --version=0.6.9

sudo -u gitlab -H bundle install --deployment --without development test postgres

sudo cp ./lib/hooks/post-receive /home/git/.gitolite/hooks/common/post-receive
sudo chown git:git /home/git/.gitolite/hooks/common/post-receive
sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production

重启gitlab  nginx服务

附:bundle show

Gems included by the bundle:
  * actionmailer (3.2.11)
  * actionpack (3.2.11)
  * activemodel (3.2.11)
  * activerecord (3.2.11)
  * activeresource (3.2.11)
  * activesupport (3.2.11)
  * acts-as-taggable-on (2.3.3)
  * arel (3.0.2)
  * backports (2.6.5)
  * bcrypt-ruby (3.0.1)
  * blankslate (3.1.2)
  * bootstrap-sass (2.2.1.1)
  * builder (3.0.4)
  * bundler (1.3.5)
  * carrierwave (0.7.1)
  * charlock_holmes (0.6.9)
  * chosen-rails (0.9.8)
  * coffee-rails (3.2.2)
  * coffee-script (2.2.0)
  * coffee-script-source (1.4.0)
  * colored (1.2)
  * daemons (1.1.9)
  * devise (2.1.2)
  * diff-lcs (1.1.3)
  * draper (0.18.0)
  * erubis (2.7.0)
  * escape_utils (0.2.4)
  * eventmachine (1.0.0)
  * execjs (1.4.0)
  * faraday (0.8.4)
  * ffaker (1.15.0)
  * font-awesome-sass-rails (2.0.0.0)
  * foreman (0.60.2)
  * gemoji (1.2.1)
  * git (1.2.5)
  * github-linguist (2.3.4)
  * github-markup (0.7.4)
  * gitlab_meta (4.0)
  * gitolite (1.1.0)
  * grack (1.0.0 ba46f3b)
  * grape (0.2.2)
  * gratr19 (0.4.4.1)
  * grit (2.5.0 7f35cb9)
  * grit_ext (0.6.1 8e6afc2)
  * haml (3.1.7)
  * haml-rails (0.3.5)
  * hashery (1.5.0)
  * hashie (1.2.0)
  * hike (1.2.1)
  * httparty (0.9.0)
  * httpauth (0.2.0)
  * i18n (0.6.1)
  * journey (1.0.4)
  * jquery-atwho-rails (0.1.7)
  * jquery-rails (2.1.3)
  * jquery-ui-rails (2.0.2)
  * json (1.7.6)
  * jwt (0.1.5)
  * kaminari (0.14.1)
  * kgio (2.7.4)
  * libv8 (3.3.10.4)
  * mail (2.4.4)
  * mime-types (1.19)
  * modernizr_rails (2.6.2.1)
  * multi_json (1.5.0)
  * multi_xml (0.5.1)
  * multipart-post (1.1.5)
  * mysql2 (0.3.11)
  * net-ldap (0.2.2)
  * oauth (0.4.7)
  * oauth2 (0.8.0)
  * omniauth (1.1.1)
  * omniauth-github (1.0.3)
  * omniauth-google-oauth2 (0.1.13)
  * omniauth-ldap (1.0.2 f038dd8)
  * omniauth-oauth (1.0.1)
  * omniauth-oauth2 (1.1.1)
  * omniauth-twitter (0.0.14)
  * orm_adapter (0.4.0)
  * polyglot (0.3.3)
  * posix-spawn (0.3.6)
  * pygments.rb (0.3.2 db1da03)
  * pyu-ruby-sasl (0.0.3.3)
  * rack (1.4.3)
  * rack-accept (0.4.5)
  * rack-cache (1.2)
  * rack-mount (0.8.3)
  * rack-protection (1.2.0)
  * rack-ssl (1.3.2)
  * rack-test (0.6.2)
  * rails (3.2.11)
  * railties (3.2.11)
  * raindrops (0.10.0)
  * rake (10.0.3)
  * raphael-rails (1.5.2)
  * rdoc (3.12)
  * redcarpet (2.2.2)
  * redis (3.0.2)
  * redis-namespace (1.2.1)
  * resque (1.23.0)
  * resque_mailer (2.1.0)
  * rubyntlm (0.1.1)
  * sass (3.2.3)
  * sass-rails (3.2.5)
  * seed-fu (2.2.0)
  * settingslogic (2.0.8)
  * sinatra (1.3.3)
  * six (0.2.0)
  * sprockets (2.2.2)
  * stamp (0.3.0)
  * therubyracer (0.10.2)
  * thin (1.5.0)
  * thor (0.16.0)
  * tilt (1.3.3)
  * treetop (1.4.12)
  * tzinfo (0.3.35)
  * uglifier (1.3.0)
  * unicorn (4.4.0)
  * vegas (0.1.11)
  * virtus (0.5.2)
  * warden (1.2.1)
  * yajl-ruby (1.1.0)
  * yaml_db (0.2.2 98e9a5d)

gitlab4.0_安装的更多相关文章

  1. kafka_2.11-2.0.0_安装部署

    参考博文:kafka 配置文件参数详解 参考博文:Kafka[第一篇]Kafka集群搭建 参考博文:如何为Kafka集群选择合适的Partitions数量 参考博文:Kafka Server.prop ...

  2. gitlab4.0_工程提交

    一,环境 gitlab         linux系统 IP :10.2.177.31   ==>(我已经申请了一个账户 A@A) 客户端      windows系统 IP:10.2.256. ...

  3. 在CentOS 7中安装与配置JDK8

    参考命令:http://www.jb51.net/os/RedHat/73016.html来进行安装 安装说明 系统环境:centos7 安装方式:rpm安装 软件:jdk-8u25-linux-x6 ...

  4. Pod 的安装

    1.如果之前已经安装过的 gem list --local | grep cocoapods 会看到如下输出: cocoapods (1.1.1)cocoapods-deintegrate (1.0. ...

  5. DotNetBar for Windows Forms 12.9.0.0_冰河之刃重打包版及制作Visual Studio C#项目模板文件详解

    关于 DotNetBar for Windows Forms 12.9.0.0_冰河之刃重打包版 --------------------11.8.0.8_冰河之刃重打包版-------------- ...

  6. DotNetBar for Windows Forms 12.1.0.0_冰河之刃重打包版 原创发布

    关于 DotNetBar for Windows Forms 12.1.0.0_冰河之刃重打包版 --------------------11.8.0.8_冰河之刃重打包版-------------- ...

  7. Linux(Ubuntu 13)下安装Eclipse

    1.本机配置及软件情况: Ubuntu版本:Ubuntukylin-13.10-desktop-i386(32位) JDK:jdk1.7.0_15(jdk-7u15-i856.gz) eclipse: ...

  8. Debian 环境下安装Tomcat记录

    1.安装JAVA运行环境 Debian默认带了OpenJDK,有人说不好用,我没有验证就从ORACLE官网上下载了最新的JDK安装包,直接解压并设置环境变量就行了: # tar zxvf jdk-8u ...

  9. CentOS7.0安装JDK1.8.0_31

    1.检查一下系统中的jdk版本 $>java -version java version "1.7.0_"OpenJDK Runtime Environment (IcedT ...

随机推荐

  1. [No0000D5]便利所有子目录更改后缀名bat

    pause for /r %%i in (.) do ( cd %%i ren *.txt *.dll ) pause

  2. 深度学习中的batch的大小对学习效果的影响

    Batch_size参数的作用:决定了下降的方向 极端一: batch_size为全数据集(Full Batch Learning): 好处: 1.由全数据集确定的方向能够更好地代表样本总体,从而更准 ...

  3. struts2 中 paramsPrepareParamsStack 拦截器

    struts2二次参数拦截器内容: 规定了请求的执行顺序 在struts2中,其拦截器为框架精华部分,而二次参数拦截器paramsPrepareParamsStack  对于解决数据回显,对象修改属性 ...

  4. Quick access recorder

    QAR_百度百科 https://baike.baidu.com/item/QAR/3300914

  5. 在SVNX中实现$Ids的自动替换

    在PHPstorm中实现$Ids的自动替换 ①.打开SVN的配置文件. [miscellany] enable-auto-props = yes [auto-props] .c = svn:keywo ...

  6. Java 输入/输出——处理流(ObjectIO)

    Object流:直接将Object流写入或读出. TestObjectIO.java transient关键字(英文名:透明的,可以用来修饰成员变量(实例变量),transient修饰的成员变量(实例 ...

  7. 2018/03/07 每日一个Linux命令 之 cat

    每日一个Linux命令 2018-03-07 Linux 命令 cat cat [-参数] fileName 在之前的Linux使用中 cat 命令一直作为文本输出指令来使用,很少可以深入学习的该命令 ...

  8. shiro默认过滤器

  9. jquery 数组的操作

    1.数组的创建 var arrayObj = new Array(); //创建一个数组 var arrayObj = new Array([size]); //创建一个数组并指定长度,注意不是上限, ...

  10. vue项目中 如何让外部引入的js模块 的this值 指向vue实例

    当前是vue项目,想在tool.js(工具模块)中封装一个跳转页面的方法, goToUrl(name,query){ if(query){ if(query.addressCode){ vueObje ...