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

[经验分享] gitlab服务安装

[复制链接]

尚未签到

发表于 2018-9-19 11:15:57 | 显示全部楼层 |阅读模式
  1、安装yum源
  yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  yum install epel*
  vim /etc/yum.repos.d/epel.repo
  baseurl去掉注释
  注释mirrorlist
  2、安装git环境所需的包
  yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make     autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel     cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
  3、移除机器上现有的git ruby
  yum -y remove git ruby
  4、安装git
  mkdir /tmp/git && cd /tmp/git
  wget https://www.kernel.org/pub/software/scm/git/git-1.8.4.1.tar.gz
  tar -zxvf git-1.8.4.1.tar.gz
  cd git-1.8.4.1/
  make prefix=/usr/local all
  make prefix=/usr/local install
  ln -fs /usr/local/bin/git* /usr/bin/
  6、安装ruby
  mkdir /tmp/ruby && cd /tmp/ruby
  curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
  cd ruby-2.0.0-p353/
  ./configure --disable-install-rdoc
  make && make install
  gem source -r https://rubygems.org/
  gem source -a http://ruby.taobao.org/
  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
  7、新建git账号并允许sudo
  useradd --comment 'GitLab' git
  echo "git ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
  8、安装git-shell
  su - git
  sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v1.8.0
  cd gitlab-shell/
  sudo -u git -H cp config.yml.example config.yml
  vim config.yml
  修改gitlab域名
  gitlab_url: "http://localhost/"
  如:
  gitlab_url: "http://gitlab.example.com/“
  :wq!
  sudo -u git -H ./bin/install
  9、使用mysql并建立gitlab数据库,本机如果没有mysql直接yum安装即可
  sudo yum -y install mysql mysql-devel mysql-server
  sudo /etc/init.d/mysqld start
  mysql -uroot -p

  CREATE USER 'gituser'@'localhost'>  CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8`     COLLATE `utf8_unicode_ci`;

  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,>  \q
  10、测试gituser登陆数据库是否正常
  sudo -u git -H mysql -u gituser -p -D gitlabhq_production
  11、安装redis
  sudo yum -y install redis
  sudo /etc/init.d/redis start
  sudo chkconfig redis on
  12、安装gitlab
  cd /home/git
  sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-4-stable gitlab
  cd /home/git/gitlab
  sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
  vim config/gitlab.yml
  13、修改git域名,上面git-shell配置文件里面定义的
  gitlab:
  ## Web server settings
  host: gitlab.example.com
  port: 80
  https: false
  14、修改git path
  git:
  bin_path: /usr/local/bin/git
  :wq!
  15、添加相应文件的权限、新建必要的文件及复制配置文件
  chown -R git log/
  chown -R git tmp/
  chmod -R u+rwX  log/
  chmod -R u+rwX  tmp/
  sudo -u git -H mkdir /home/git/gitlab-satellites
  sudo -u git -H mkdir tmp/pids/
  sudo -u git -H mkdir tmp/sockets/
  sudo chmod -R u+rwX tmp/pids/
  sudo chmod -R u+rwX tmp/sockets/
  sudo -u git -H mkdir public/uploads
  sudo chmod -R u+rwX public/uploads/
  sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
  sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
  16、设置gitlab全局账号
  sudo -u git -H git config --global user.name "GitLab"
  sudo -u git -H git config --global user.email "gitlab@localhost"
  sudo -u git -H git config --global core.autocrlf input
  17、设置数据库连接文件信息,如下是我数据库信息配置:
  sudo -u git cp config/database.yml.mysql config/database.yml
  sudo -u git -H vim config/database.yml
  #
  # PRODUCTION
  #
  production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_production
  pool: 10
  username: gituser
  password: "gitpasswd”
  # host: localhost
  # socket: /tmp/mysql.sock
  #
  # Development specific
  #
  development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_development
  pool: 5
  username: gituser
  password: "gitpasswd”
  # socket: /tmp/mysql.sock
  # Warning: The database defined as "test" will be erased and
  # re-generated from your development database when you run "rake".
  # Do not set this db to the same as development or production.
  test: &test
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_test
  pool: 5
  username: gituser
  password: "gitpasswd”
  # socket: /tmp/mysql.sock
  18、安装gems
  cd /home/git/gitlab
  vim Gemfile
  修改source "https://rubygems.org/"
  为source "https://ruby.taobao.org/"
  vim Gemfile.lock
  修改remote: https://rubygems.org/
  为remote: https://ruby.taobao.org/
  :wq
  sudo -u git -H bundle install --deployment --without development test postgres aws
  19、如出现此类错误Could not find modernizr-2.6.2 in any of the sources,则修改:
  vim Gemfile
  修改:gem "modernizr",        "2.6.2"
  为gem "modernizr-rails",  "2.7.1"
  :wq
  20、vim Gemfile.lock
  修改:modernizr (2.6.2)
  为:modernizr-rails (2.7.1)
  修改:modernizr (= 2.6.2)
  为:modernizr-rails (= 2.7.1)
  :wq
  再次运行:sudo -u git -H bundle install --deployment --without development test postgres aws
  21、初始化数据库
  sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
  Do you want to continue (yes/no)? yes
  初始化完成后最后两行就是你gitlab默认的用户名密码
  22、配置启动及日志切割文件
  sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
  sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
  sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
  测试环境信息
  sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
  23、安装nginx
  sudo yum -y install nginx
  以下是我nginx主配置文件内容
  cat /etc/nginx/nginx.conf | grep -v "^#" | grep -v "^$"
  user              root git;
  worker_processes  2;
  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"';
  upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
  }
  server {
  listen *:80 default_server;
  server_name gitlab.example.com;
  server_tokens off;
  root /home/git/gitlab/public;
  client_max_body_size 5m;
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;
  location / {
  try_files $uri $uri/index.html $uri.html @gitlab;
  }
  location @gitlab {
  proxy_read_timeout 300;
  proxy_connect_timeout 300;
  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_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
  proxy_pass http://gitlab;
  }
  }
  #tcp_nopush     on;
  #keepalive_timeout  0;
  #gzip  on;
  # Load config files from the /etc/nginx/conf.d directory
  # The default server is in conf.d/default.conf
  }
  24、更改权限及启动nginx
  sudo nginx -t
  sudo chown -R git.git /var/lib/nginx/
  sudo /etc/init.d/nginx start
  25、拉取gitlab静态资源文件
  sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
  26、启动gitlab
  sudo /etc/init.d/gitlab start
  检查各个组件是否正常工作
  sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
  28、一切正常的话 使用你的浏览器访问gitlab吧(域名访问,修改hosts文件先)
  http://gitlab.example.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-594195-1-1.html 上篇帖子: 使用bitnami部署gitlab的邮件提醒配置 下篇帖子: Gitlab代码管理平台部署(CentOS6.7—gitlab7.2.12)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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