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

[经验分享] Centos6.2 + gitlab安装小结

[复制链接]

尚未签到

发表于 2018-9-19 11:36:49 | 显示全部楼层 |阅读模式
  Centos6.2 + gitlab安装小结
  1.Gitlab介绍及安装要求
  介绍:GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。GitLab 要求服务器端采用 Gitolite 搭建,5.0版本以后对于ssh服务,GitLab不再使用 Gitolite ,采用自己开发的 gitlab-shell 来实现。另外,如果需要对代码进行Review,推荐使用Gerrit,要复杂一些,但是功能非常强大。
  安装GitLab的需求:Ubuntu/Debian(官方推荐这2个系统,也可以安装到CentOS系统中,并且在GitHub上有CentOS的GitLab一键安装脚本https://github.com/mattias-ohlsson/gitlab-installer/blob/master/gitlab-install-el6.sh)
  前提:一定要先关闭iptable与selinux
  本文安装的系统为centos 6.2 X86_64位系统,安装在DELL R510机器,使用的nginx+php+mysql已经部署好了的环境。安装前强烈推荐阅读该帮助手册:
  https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md
  2. 安装:
  2.1. install Packages /Dependencies
  cd /u1/zdh
  rpm -ivh\
  http://fr2.rpmfind.net/linux/epel/6/x86_64/epel-release-6-8.noarch.rpm
  yum -y install readline-devel  libyaml-devel gdbm-devel  ncurses-develredis openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-develcurl-devel expat-devel gettext-devel  tk-devel  libxml2-devellibffi-devel libxslt-devel libicu-devel httpd httpd-devel gitolite git-allpython-devel python-pip sqlite-devel sendmail vim mysql-devel mysql-serverpatch libyaml* pcre-devel
  2.2 install ruby1.9+(此过程网络慢的情况下可能时间长点)
  mkdir /tmp/ruby&& cd /tmp/ruby
  curl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xz
  yum -y removeruby  #移除老版本
  cd ruby-1.9.3-p392/
  ./configure
  make && make install
  gem install bundler --no-ri --no-rdoc
  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
  2.3 create system user
  adduser --comment 'GitLab'git
  chmod -R 755 /home/git
  2.4 install gitlab shell
  su - git
  cd /home/git
  git clone https://github.com/gitlabhq/gitlab-shell.git
  cd gitlab-shell
  git checkout v1.7.0
  cp config.yml.example config.yml
  vim config.yml
  user: git
  gitlab_url: "http://gitlab.linuxblind.com/"
  http_settings:
  self_signed_cert: false
  repos_path: "/home/git/repositories"
  auth_file: "/home/git/.ssh/authorized_keys"
  redis:
  bin:/usr/bin/redis-cli
  host:127.0.0.1
  port:6379
  #socket: /tmp/redis.socket
  namespace:resque:gitlab
  ./bin/install
  2.5 install database
  mysql -u root -p
  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, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,>  mysql>\q
  2.6 install gitlab
  #clone the source
  su - git
  cd /home/git
  git clone https://github.com/gitlabhq/gitlabhq.git gitlab
  cd /home/git/gitlab
  git checkout 5-4-stable
  #configure it
  cd /home/git/gitlab
  cp config/gitlab.yml.example config/gitlab.yml
  vim config/gitlab.yml
  gitlab:
  host:gitlab.linuxblind.com
  port:80
  https:false
  email_from:gitlab@localhost
  support_email: support@localhost
  default_projects_limit: 10
  satellites:
  path:/home/git/gitlab-satellites/
  backup:
  path:"tmp/backups
  #keep_time: 604800
  gitlab_shell:
  repos_path: /home/git/repositories/
  hooks_path:/home/git/gitlab-shell/hooks/
  upload_pack:true
  receive_pack:true
  git:
  bin_path:/usr/local/bin/git
  max_size: 5242880
  timeout: 10
  chown -R git log/
  chown -R git tmp/
  chmod -R u+rwX  log/
  chmod -R u+rwX  tmp/
  mkdir /home/git/gitlab-satellites
  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/puma.rb.example config/puma.rb
  #locate unicorn.rb
  #cp /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/redis-3.0.4/examples/\
  unicorn/unicorn.rb /home/git/gitlab/config/
  #vim config/unicorn.rb
  git config --global user.name "GitLab"
  git config --global user.email "gitlab@localhost"
  git config --global core.autocrlf input
  2.7 config mysql
  su - git
  cp config/database.yml.mysql config/database.yml
  vim 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
  development:
  adapter:mysql2
  encoding:utf8
  reconnect:false
  database:gitlabhq_development
  pool:5
  username:gitlab
  password:"gitlab"
  socket:/tmp/mysql.sock
  test: &test
  adapter:mysql2
  encoding:utf8
  reconnect:false
  database:gitlabhq_test
  pool:5
  username:gitlab
  password:"gitlab"
  socket:/tmp/mysql.sock
  chmod o-rwx config/database.yml
  2.8 install gem
  cd /home/git/gitlab
  gem install charlock_holmes --version '0.6.9.4'
  bundle install --deployment --without development test postgres unicorn aws
  2.9 Initialize database and activateadvanced features
  /etc/init.d/redis start
  /usr/local/mysql/bin/mysqld--defaults-file=/usr/local/mysql/my.cnf &
  bundle exec rake gitlab:setup RAILS_ENV=production
  2.10 install init script
  cd /home/git/gitlab
  cp lib/support/init.d/gitlab /etc/init.d/gitlab
  chmod +x /etc/init.d/gitlab
  #cat /etc/init.d/gitlab
  APP_ROOT="/home/git/gitlab"
  APP_USER="git"
  DAEMON_OPTS="-C $APP_ROOT/config/puma.rb"
  PID_PATH="$APP_ROOT/tmp/pids"
  SOCKET_PATH="$APP_ROOT/tmp/sockets"
  WEB_SERVER_PID="$PID_PATH/puma.pid"
  SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
  STOP_SIDEKIQ="RAILS_ENV=production bundle exec rakesidekiq:stop"
  START_SIDEKIQ="RAILS_ENV=production bundle exec rakesidekiq:start"
  NAME="gitlab"
  DESC="GitLabservice"
  2.11 check application status
  #Check if GitLab and its environment are configured correctly:
  bundle exec rake gitlab:env:info RAILS_ENV=production
  #To make sure you didn't miss anything run a more thorough check with:
  bundle exec rake gitlab:check RAILS_ENV=production
  #If all items are green, then congratulations on successfully
  #if getwronglike“ Running? ... no”,Try fixing it with:
  bundle exec rake sidekiq:start RAILS_ENV=production
  2.12 start gitlab service
  sudo gitlab start (or: sudo /etc/init.d/gitlab start)
  2.13 install nginx and configure gitlab fornginx
  cd /home/git/gitlab
  cp lib/support/nginx/gitlab /usr/local/nginx/conf/sites-enabled/gitlab.conf
  chown -R nobody.nobody /usr/local/nginx
  #cat nginx.conf
  user  nobody nobody;
  worker_processes 4;
  error_log logs/error.log;
  events {
  worker_connections  1024;
  }
  http {
  include       mime.types;
  default_type  application/octet-stream;
  sendfile        on;
  tcp_nopush     on;
  tcp_nodelay     off;
  keepalive_timeout 65;
  gzip  on;
  gzip_comp_level 1;
  gzip_proxiedany;
  gzip_types text/plain text/css application/x-javascripttext/xml application/xml application/xml+rss text/javascript;
  include /usr/local/nginx/conf/sites-enabled/*;
  }
  #cat gitlab.conf
  upstream gitlab {
  serverunix:/home/git/gitlab/tmp/sockets/gitlab.socket;
  }
  server {
  listen80;         # e.g., listen192.168.1.1:80;
  server_name gitlab.linuxblind.com;
  root/home/git/gitlab/public;
  access_log /usr/local/nginx/logs/gitlab_access.log;
  error_log   /usr/local/nginx/logs/gitlab_error.log;
  location/ {
  try_files $uri $uri/index.html $uri.html@gitlab;
  }
  location@gitlab {
  proxy_read_timeout300;
  proxy_connect_timeout300;
  proxy_redirect     off;
  proxy_set_header   X-Forwarded-Proto $scheme;
  proxy_set_header   Host              $http_host;
  proxy_set_header   X-Real-IP         $remote_addr;
  proxy_pass http://gitlab;
  }
  }
  /usr/local/nginx/sbin/nginx
  3. 访问
  http://gitlab.linuxblind.com/用户名:admin@local.host 密码:5iveL!fe



运维网声明 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-594215-1-1.html 上篇帖子: 在centos里安装gitlab 下篇帖子: Gitlab的管理使用手册
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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