• centos 7 安装gitlab


    https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/requirements.md

    #配置安装EPEL及依赖环境

    #更新包     
    yum update      
    yum -y install wget      

    yum -y --nogpgcheck install http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
    #添加epel源      
    http://www.cnblogs.com/Irving/p/3729074.html    
    #安装所需依赖包     
    yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis wget crontabs logwatch logrotate perl-Time-HiRes git gettext-devel libel openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-devel expat-devel gettext-devel tk-devel  libxml2-devel libffi-devel libxslt-devel libicu-devel python-pip sqlite-devel  patch libyaml* pcre-devel cmake

    #安装Git

    http://www.cnblogs.com/Irving/p/3729064.html    
    #创建一个Git用户供GitLab使用     
    adduser --comment 'GitLab' git      
    passwd git      
    #为了方便添加git用户拥有root权限      
    vi /etc/sudoers      
    git  ALL=(ALL)    ALL      
    #强制保存      
    :wq!      
    #设置权限(重要)      
    sudo chmod o+x /home/git      

    su git
    vi /home/git/.bash_profile      
    export GIT_SSL_NO_VERIFY=1      
    source /home/git/.bash_profile      
    #不添加变量的话使用https链接会报如下错误      
    fatal: unable to access 'https://github.com/gitlabhq/grit.git/': Peer certificate cannot be authenticated with known CA certificates

    #安装MYSQL


    sudo yum install mariadb mariadb-devel    mariadb-server

     sudo cp /etc/my.cnf /etc/my.cnf.bak

    sudo cp /usr/share/mysql/my-huge.cnf /etc/my.cnf 

    sudo systemctl start mariadb.service #启动MariaDB

    sudo systemctl stop mariadb.service #停止MariaDB

    sudo systemctl restart mariadb.service #重启MariaDB

    sudo systemctl enable mariadb.service #设置开机启动

     
    #设置mysql root账号的密码      
    sudo /usr/bin/mysql_secure_installation

    创建gitlab使用的数据库     
    mysql -u root -p      
    #创建用户      
    CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab登陆密码';      
    #创建数据库      
    CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;      
    #设置权限      
    GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';      
    quit      

    #安装Ruby(需要添加rubygems的国内镜像)      

    Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.org/ )源来查找、安装、升级和卸载软件包,非常的便捷。

    sudo yum -y install rubygems  ruby ruby-devel  

    $ gem sources --remove https://rubygems.org/
    $ gem sources -a https://ruby.taobao.org/
    $ gem sources -l

    gem install bundler --no-ri --no-rdoc      
    ruby -v

    #安装GitLab的Shell     

    cd /home/git

    git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v2.1.0      #指定最新标准版 v2.1.0     
    cd gitlab-shell/      
    cp config.yml.example config.yml      
    vi config.yml      
    #配置gitlab域名      
    gitlab_url: "http://git.test.com/"    
    #果gitlab是使用https访问     
    self_signed_cert:true      
    #安装      
    ./bin/install      
    CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '123456';

     

    #安装GitLab

    cd /home/git
    git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-8-stable gitlab     
    cd gitlab      
    #复制配置文件      
    cp config/gitlab.yml.example config/gitlab.yml      
    #修改访问域名      
    vi config/gitlab.yml      
    ## Web server settings      
      host: git.test.com      
      port: 80      
      https: true      
    #配置权限      
    chown -R git log/      
    chown -R git tmp/      
    chmod -R u+rwX  log/      
    chmod -R u+rwX  tmp/      
    mkdir tmp/pids/      
    mkdir tmp/sockets/      
    chmod -R u+rwX  tmp/pids/      
    chmod -R u+rwX  tmp/sockets/      
    mkdir public/uploads      
    chmod -R u+rwX  public/uploads      
    cp config/unicorn.rb.example config/unicorn.rb      
    cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb      
    #配置git的用户和邮件      
    git config --global user.name "GitLab"      
    git config --global user.email "gitlab@localhost"      
    git config --global core.autocrlf input

    #配置gitlab数据库     
    cp config/database.yml.mysql config/database.yml      
    vi config/database.yml      
    production:      
      adapter: mysql2      
      encoding: utf8      
      reconnect: false      
      database: gitlabhq_production      
      pool: 5      
      username: gitlab      
      password: "gitlab"      
      # host: localhost      
      # socket: /tmp/mysql.sock      

    #安装gems

    cd cd /home/git/gitlab

    $ gem install charlock_holmes --version '0.6.9.4'      
    vi Gemfile      
    source "https://rubygems.org"改为source "http://rubygems.org"或改成    source  "https://ruby.taobao.org/"
    #安装     
    bundle install --deployment --without development test postgres puma aws

    山东大学的源 http://ruby.sdutlinux.org/

    #启动redis服务

    sudo /etc/init.d/redis start     
    sudo chkconfig redis on      
    #初始化数据库      
    bundle exec rake gitlab:setup RAILS_ENV=production      
    #默认账号和密码      
    Administrator account created:      
    login.........admin@local.host      
    password......5iveL!fe

    #拉取GitLab静态文件

    cd /home/git/gitlab     
    bundle exec rake assets:precompile RAILS_ENV=production

    #检查应用程序状况     
    bundle exec rake gitlab:env:info RAILS_ENV=production

    #安装启动脚本

    sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn -P /etc/init.d/     
    sudo mv /etc/init.d/gitlab-unicorn /etc/init.d/gitlab      
    sudo chmod +x /etc/init.d/gitlab      
    sudo chkconfig --add gitlab      
    sudo chkconfig gitlab on      
    sudo /etc/init.d/gitlab start

    #安装Nginx

    #安装
    sudo yum -y install nginx

    systemctl enabled nginx

    #拷贝gitlab配置     
    cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/conf.d/      
    #备份默认配置      
    mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.back      
    #重盖默认配置(或者删除default.conf 默认配置,只用gitlab)      
    mv /etc/nginx/conf.d/gitlab /etc/nginx/conf.d/default.conf

    #启动服务

    #service gitlab start (restart)     
    #service nginx start  (restart)      
    #关闭防火墙 (重启后永久性生效)      
    service iptables stop      
    chkconfig iptables off      
    #访问服务      
    http://192.168.0.107/

    image


    基本查看网上的文章安装,还算比较顺利,我这边遇到如下问题:       
    1.ruby 最新源码编译很久不能通过,换到低一个版本        
    2.502错误,因为Nginx默认配置了502错误,查看Nginx日志 /var/log/nginx/gitlab_error.log         
    "/home/git/gitlab/public/favicon.ico.html" failed (13: Permission denied), client: 33.33.33.1, server: gitlab.web.lo, request: "GET /favicon.ico HTTP/1.1"        
    开始以为是Socet服务有问题,后发现是权限问题。        
    解决方法:chmod o+x /home/git

    Refer:       
    用Gitlab来工作        
    http://feiyang.me/2013/03/work-with-gitlab/      
    Puma 替换 Unicorn 跑 Gitlab       
    http://icyleaf.com/2014/01/moving-unicorn-to-puma-on-gitlab/      
    GitLab 启用HTTPS        
    http://blog.csdn.net/csfreebird/article/details/8579488      
    Ubuntu       
    http://my.oschina.net/guol/blog/165409      
    http://rfyiamcool.blog.51cto.com/1030776/1365521/      
    Redhat       
    http://my.oschina.net/xiaokaceng/blog/187573      
    CentOS       
    http://my.oschina.net/wzlee/blog/262181      
    http://hypocritical.blog.51cto.com/3388028/1405574

  • 相关阅读:
    P1246 编码
    P2638 安全系统
    P3913 车的攻击
    P2789 直线交点数
    What?100%基于深度强化学习的对冲基金
    AI | 重磅推荐!哥大开源“FinRL”:一个用于量化金融自动交易的深度强化学习库
    神经霍克斯过程:一个基于神经网络的自调节多变量点过程
    量化都玩IPU了?Man Group-Oxford研究所给你答案
    为什么数字资产生态系统能够增长到2万亿美元以上?
    ICML 获奖者陆昱成:去中心化机器学习的理论极限在哪里?
  • 原文地址:https://www.cnblogs.com/zhepama/p/4080279.html
Copyright © 2020-2023  润新知