• gitlab4.0_安装


    一,安装环境

    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 %b " "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)

  • 相关阅读:
    VS2012 Unit Test(Void, Action, Func) —— 对无返回值、使用Action或Func作为参数、多重载的方法进行单元测试
    string中Insert与Format效率对比、String与List中Contains与IndexOf的效率对比
    VS2012 Unit Test —— 我对接口进行单元测试使用的技巧
    委托又给我惹麻烦了————记委托链的取消注册、获取返回值
    委托的N种写法,你喜欢哪种?
    VS2012 单元测试之泛型类(Generics Unit Test)
    Unity V3 初步使用 —— 为我的.NET项目从简单三层架构转到IOC做准备
    使用NuGet助您玩转代码生成数据————Entity Framework 之 Code First
    JqueryEasyUI浅谈---视频教程公布
    JqueryEasyUI浅谈本地化应用
  • 原文地址:https://www.cnblogs.com/zy1234567/p/9939083.html
Copyright © 2020-2023  润新知