zhufeng518 发表于 2018-9-19 11:02:52

centos 6.5安装GitLab安装

设置mysql root账号的密码:  # mysqladmin -u root password '123456'
  创建新用户和数据库给gitlab使用
  # 登录数据库
  # mysql -u root -p
  # 输入root密码
  # 为gitlab创建使用用户

  CREATE USER 'gitlab'@'localhost'>  # 创建gitlaba使用的数据库
  CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  # 给予gitlab用户权限

  GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,>  # 登出数据库
  \q
  6、安装GitLab
  将GitLab安装在git的家目录下:
  #su - git
  a、克隆GitLab并切换分支到6-3-stable
  # 克隆GitLab
  $ git clone https://github.com/gitlabhq/gitlabhq.git gitlab
  # 进入gitlab目录
  $ cd /home/git/gitlab
  # 切换到6-3-stable分支
  $ git checkout 6-3-stable
  b、配置项目
  复制配置文件
  $ cp config/gitlab.yml.example config/gitlab.yml
  修改配置文件中
  $ sed -i 's|localhost|192.169.1.171|g' config/gitlab.yml
  备注:192.168.1.171是我要安装的机器
  设定log和tmp目录所有者和权限
  $ chown -R git log/
  $ chown -R git tmp/
  $ chmod -R u+rwX log/
  $ chmod -R u+rwX tmp/
  创建gitlab-satellites目录
  $ mkdir /home/git/gitlab-satellites
  创建tmp/pids/和tmp/sockets/目录,确保gitlab有相应的权限
  $ mkdir tmp/pids/
  $ mkdir tmp/sockets/
  $ chmod -R u+rwX tmp/pids/
  $ chmod -R u+rwX tmp/sockets/
  创建public/uploads目录
  $ mkdir public/uploads
  $ chmod -R u+rwX public/uploads
  复制unicorn配置
  $ cp config/unicorn.rb.example config/unicorn.rb
  编辑resque.yml配置
  $ vim config/resque.yml
  development: redis://192.168.1.171:6379
  test: redis://192.168.1.171:6379
  production: redis://192.168.1.171:6379
  配置git的用户和邮件
  $ git config --global user.name "GitLab"
  $ git config --global user.email "bb@aa.com"(以你真实的域名填写)
  $ git config --global core.autocrlf input
  c、配置数据库访问文件
  $ cp config/database.yml.mysql config/database.yml
  编辑config/database.yml,设置其中连接数据库的账号密码,笔者的配置部分如下:
  # PRODUCTION
  #
  production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: gitlabhq_production
  pool: 10
  username: gitlab
  password: "123456"
  # host: localhost
  # socket: /tmp/mysql.sock
  修改其中username和password就可以了,其中密码就是上面数据库步骤中创建gitlab用户的密码。
  确保该文件只有git账号有权限读取。
  $ chmod o-rwx config/database.yml
  d、安装Gems
  $ su -
  # gem install charlock_holmes --version '0.6.9.4'
  # exit
  安装mysql包
  $ su - git
  $ cd /home/git/gitlab/
  $ bundle install --deployment --without development test postgres puma aws
  备注:
  [转]Could not find modernizr-2.6.2 in any of the sources 解决办法:
  $ vi Gemfile
  source "https://rubygems.org"改为source "http://rubygems.org"
  $ bundle install --deployment--without development test postgres
  Fetching source indexfrom http://rubygems.org/
  Fetchinghttps://github.com/gitlabhq/grit.git
  Could not findmodernizr-2.6.2 in any of the sources
  #出现错误:Could not find modernizr-2.6.2 in any of thesources
  #解决办法:
  $ vi Gemfile
  第114行   gem"modernizr",       "2.6.2"
  更改改为:
  第114行   gem "modernizr-rails","2.7.1"
  $ vi Gemfile.lock
  第252行   modernizr (2.6.2)
  更改改为:
  第252行   modernizr-rails (2.7.1)
  第523行   modernizr (= 2.6.2)
  更改改为:
  第523行   modernizr-rails (= 2.7.1)
  #重新执行:
  $ bundleinstall --deployment --without development test postgres puma aws
  e、初始化数据和激活高级功能
  $ cd /home/git/gitlab
  $ bundle exec rake gitlab:setup RAILS_ENV=production
  这步完成后,会生一个默认的管理员账号:
  admin@local.host
  5iveL!fe
  f、安装启动脚本
  # cd /home/git/gitlab
  # cp lib/support/init.d/gitlab /etc/init.d/
  # chmod +x /etc/init.d/gitlab
  设置logarate
  # cd /home/git/gitlab
  # cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
  # chkconfig --add gitlab
  开机时启动
  # chkconfig gitlab on
  g、检测应用程序状态
  $ su - git
  $ cd gitlab/
  $ bundle exec rake gitlab:env:info RAILS_ENV=production
  $ exit
  可以查看到系统、Ruby、GitLab和GitLabShell的版本和其他信息。
  启动GitLab实例
  $ service gitlab start
  h、查看应用更加详细的信息
  $ su - git
  $ cd gitlab/
  $ bundle exec rake gitlab:check RAILS_ENV=production
  7、安装web服务器
  选择的是nginx,
  $ su -
  # yum -y install nginx
  # chkconfig nginx on
  # mkdir /etc/nginx/sites-available
  # mkdir /etc/nginx/sites-enabled
  #cd /home/git/gitlab# cp lib/support/nginx/gitlab /etc/nginx/sites-available/
  # ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
  修改域名
  vim /etc/nginx/sites-enabled/gitlab
  server_name 192.168.1.171;
  修改nginx配置文件其中
  # Load configfiles from the /etc/nginx/conf.d directory
  # The defaultserver is in conf.d/default.conf
  #    include/etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
  }
  重启服务
  #/etc/init.d/nginx restart
  8 测试
  访问:http://192.168.1.171/


页: [1]
查看完整版本: centos 6.5安装GitLab安装