设为首页 收藏本站
查看: 1632|回复: 0

[经验分享] linux下搭建gitlab-Henry

[复制链接]

尚未签到

发表于 2018-9-19 11:27:17 | 显示全部楼层 |阅读模式
  
  GitLab
  GitLab,是一个使用 Ruby on Rails 开发的开源应用程序,与Github类似,能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用。
  官方只提供了Debian/Ubuntu系统下的安装说明文档,如果需要在centos下安装,可以参考这篇:https: //github.com/gitlabhq/gitlab-recipes/tree/master/install/centos,笔者依照这篇文章的说明,成功的在centos系统上安装了gitlab,分享一下自己的安装过程和碰到的问题。
  安装步骤总览

  •   基础操作系统(CentOS 6.5)
  •   Ruby (版本: 2.0.0p353)
  •   创建项目运行用户(创建git账号,方便权限管理)
  •   GitLab Shell(版本:1.8.0)
  •   数据库(可以支持mysql和PostgreSQL,这里使用mysql,版本:5.1.17)
  •   GitLab(版本:6.3.1)
  •   Web服务器(可支持nginx和apache,这里使用nginx,版本:1.0.15)
  •   Ip地址:10.0.247.136
  1,准备工作:
  a,安装wget,增加EPEL安装源
  [root@localhost ~]# yum -y install wget
  下载并安装GPG key
  wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6https://www.fedoraproject.org/static/0608B895.txt
  rpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
  检验是否安装成功
  rpm  –qa gpg*
  安装epel-release-6-8.noarch包
  rpm -Uvhhttp://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  b、增加PUIAS安装源
  PUIASLinux是面向桌面和服务器的完整的操作系统,它靠编译Red Hat Enterprise Linux的源代码包来创建。除了这些上游的软件包外,该项目还提供一些其他的软件仓库:“Addons”包含了通常的Red Hat发行中未收入的额外软件包,“Computational”提供专门针对科学计算的软件,“Unsupported”则收入各种各样的测试性软件包。该发行由美国普林斯顿 大学的高等研究所维护。
  创建/etc/yum.repos.d/PUIAS_6_computational.repo,并添加如下内容:
  [PUIAS_6_computational]
  name=PUIAScomputational Base $releasever - $basearch
  mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist
  #baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias
  下载并安装GPG key
  Wget   -O  /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
  http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
  rpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
  检验是否安装成功:
  [root@localhost yum.repos.d]# rpm -qa|grepgpg*
  gpgme-1.1.8-3.el6.x86_64
  pygpgme-0.1-18.20090824bzr68.el6.x86_64
  libgpg-error-1.7-4.el6.x86_64
  gpm-libs-1.20.6-12.el6.x86_64
  gpg-pubkey-41a40948-4ce19266
  gpg-pubkey-c105b9de-4e0fd3a3
  gpg-pubkey-0608b895-4bd22942
  重新加载源文件:[root@localhost ~]# yum repolist
  C,安装GitLab的所需依赖包和工具
  yum -ygroupinstall 'Development Tools'
  $ yum-y install vim-enhanced readline readline-devel ncurses-devel gdbm-develglibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byaccsqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2libxml2-devel libxslt libxslt-devel libicu libicu-develsystem-config-firewall-tui python-devel redis sudo wget crontabs logwatchlogrotate perl-Time-HiRes git
  RHEL提示:
  如果部分包不能安装,例如: eg. gdbm-devel, libffi-devel and libicu-devel,就去rpmgind.net网站中找取,就行安装。
  d、配置redis
  配置redis使其在开机时启动:
  chkconfig redis on
  service redis start
  2、安装Ruby
  [root@localhost~]# mkdir /tmp/ruby && cd /tmp/ruby
  [root@localhostruby]# curl --progressftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
  [root@localhostruby]# cd ruby-2.0.0-p353/
  [root@localhostruby-2.0.0-p353]# ./configure --prefix=/usr/local/
  [root@localhostruby-2.0.0-p353]# make && make install
  检验是否安装成功:
  [root@localhostruby-2.0.0-p353]# ruby -v
  ruby2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
  a,修改 gem 源指向taobao
  [root@localhost~]# gem source -r https://rubygems.org/
  [root@localhost~]# gem source -a http://ruby.taobao.org/
  [root@localhost~]# gem source -l
  http://ruby.taobao.org/
  b,安装 Bundel 命令
  geminstall bundler --no-ri --no-rdoc
  给Gitlab创建一个系统用户
    [root@localhost ~]# adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git    c,Gitlab shell   下载 Gitlab Shell,用来 ssh 访问仓库的管理软件cd /home/gitsudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.gitcd gitlab-shellsudo -u git -H cp config.yml.example config.yml修改gitlab-shell/config.yml  [root@localhost git]# sudo -u git -Hvim /home/git/gitlab-shell/config.yml
  Gitlab_url: http://gitlab.thstack.com/
  安装 gitlab-shell
  cd /home/git/gitlab-shell
  sudo -u git-H ./bin/install
  (注:此处要注意权限问题,执行./bin/install时属主.属组都是git)
  d,安装mysql
  此处使用的yum安装的,根据不同环境进行选择,线上环境建议使用tar.gz包进行安装。
   Yum –yinstall mysql-server mysql-devel mysql
  Servicemysqld restart
  Mysql–uroot –p
  mysql>create database gitlabdb;
  Query OK, 1 row affected (0.00 sec)

  mysql> grant all on gitlabdb.* to'gitlab'@'localhost'>  Query OK, 0 rows affected (0.01 sec)

  GRANT SELECT,LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,>  e, Gitlab安装
  下载Gitlab 源代码,并切换到最新的分支上
  [root@www ~]# cd /home/git/
  [root@www git]# sudo -u git -H git clonehttps://github.com/gitlabhq/gitlabhq.git gitlab
  [git@www gitlab]$ git checkout 6-4-stable
  配置GitLab,修改gitlab.yml,其中host项和gitlab-shell gitlab_url 的主机一致
  cd /home/git/gitlab
  cp config/gitlab.yml.example config/gitlab.yml
  vim config/gitlab.yml
  host: gitlab.thstack.com
  email_from: gitlab@thstack.com
  support_mail: gitlab@thstack.com
  signup_enabled: true             #开启用户注册
  创建相关目录
  [git@www gitlab]$ mkdir tmp/pids
  [git@www gitlab]$ mkdir tmp/sockets
  [git@www gitlab]$ mkdir/home/git/gitlab-satellites
  修改相关目录权限:如上面所说属主属组都为git
  修改unicorn.rb 监听端口为:8081
  cpconfig/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
  cpconfig/unicorn.rb.example config/unicorn.rb
  vimconfig/unicorn.rb
  listen"gitlab.thstack.com:8081", :tcp_nopush => true
  配置GitLab访问mysql数据库设置:
  [git@www config]$ cpdatabase.yml.mysql database.yml
  [git@www config]$ vim database.yml
  *修改 Production 部分:*
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database:gitlabdb
  pool: 10
  username: gitlab
  password: "gitlab”
  (此为可选项) 设置GitLab 使用指定邮箱发送邮件,注意production.rb 的文件格式,开头空两格
      vim config/environments/production.rb  #修改 :sendmail 为 :smtp
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings= {
  :address              =>"smtp.googlemail.com",
  :port                 => 587,
  :domain               => 'thstack.com',
  :user_name            => 'gitlab@thstack.com',
  :password             => 'password',
  :authentication       => :plain,
  :enable_starttls_auto => true
  }
  end          # 上面内容加入到 end 里面
  安装gem
  修改Gemfile文件中源指向taobao
  [git@www gitlab]$ vim Gemfile
  [git@www gitlab]$ head -1 Gemfile
  source http://ruby.taobao.org/
  安装mysql包:
  [git@www gitlab]$ bundle install --deployment--without development test postgres aws
  此时会报错:Could not find modernizr-2.6.2 in any of the sources            
  首先把git的gem源修改为taobao,
  Gem source –r https://rubygems.org/
  Gem source –a http://ruby.taobao.org/
  修改Gemfile文件:
  Gem“modernizr”  “2.6.2” ===> gem “modernizr-rails”  “2.7.1”
  修改Gemfile.lock:
  modernizr  (2.6.2)  ===>     modernizr-rails(2.7.1)
  modernizr  (2.6.2)  ===>     modernizr-rails (=2.7.1)
  初始化数据库并激活高级功能:
  [git@www gitlab]$  bundle exec rake gitlab:setupRAILS_ENV=production
  此处出现问题:首先想到数据库授权,然后是database.yml 文件,当出现
  Do you want to continue (yes/no)?请输入yes,(y|n都会出现错误)
  Do you wantto continue (yes/no)? yes
  ...
  Administratoraccount created:
  login.........admin@local.host
  password......5iveL!fe
  设置Gitlab启动服务:
  Cd/home/git/gitlab
  [git@wwwgitlab]$ sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
  设置Gitlab使用logrotate备份Log
  [git@wwwgitlab]$ sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
  检查Gitlab及其环境的配置是否正确:
  [git@wwwgitlab]$ bundle exec rake gitlab:env:info RAILS_ENV=production
  System information
  System:            CentOSrelease 6.5 (Final)
  Current User:      git
  Using RVM:no
  Ruby Version:      2.0.0p353
  Gem Version:       2.0.14
  Bundler Version:1.9.9
  Rake Version:      10.1.0
  GitLab information
  Version:   6.4.3
  Revision:  3173626
  Directory:/home/git/gitlab
  DB Adapter:mysql2
  URL:       http://gitlab.thstack.com
  HTTP Clone URL:    http://gitlab.thstack.com/some-project.git
  SSH Clone URL:     git@gitlab.thstack.com:some-project.git
  Using LDAP:no
  Using Omniauth:    no
  GitLab Shell
  Version:   2.6.3
  Repositories:      /home/git/repositories/
  Hooks:             /home/git/gitlab-shell/hooks/
  Git:       /usr/bin/git
  最后搭建nginx,使用nginx代理到本机的8081端口上就行了。



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-594206-1-1.html 上篇帖子: 版本控制之gitlab实战部署 下篇帖子: gitlab部署、配置更改、备份及恢复
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表