centos6.5x64源码编译安装gitlab7.9.2
centos6.5x64源码编译安装gitlab7.9.2
centos6.5x64安装gitlab7.9.2
安装gitlab
注意,以下一到五步骤都需要用root用户操作
一:初始化安装环境
yum -ygroupinstall 'Development Tools'
yum -yinstall readline readline-devel ncurses-devel gdbm-devel glibc-develtcl-devel openssl-devel curl-devel expat-devel db4-devel byaccsqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2libxml2-devel libxslt libxslt-devel libicu libicu-develsystem-config-firewall-tui crontabs logwatch logrotateperl-Time-HiRes cmakelibcom_err-devel.i686 libcom_err-devel.x86_64 zlib-devel perl-CPANgettext gettext-devel
二:安装GIT
确保git版本至少在1.7.10或以上,如果不是,卸载重装
yum -y remove git
mkdir /tmp/git && cd /tmp/git
curl --progress https://www.kernel.org/pub/software/scm/git/git-2.1.3.tar.gz | tar xz
cd git-2.1.3/
./configure
make
make prefix=/usr/local install
创建软连接
ln -s /usr/local/bin/git /usr/bin/git
三:安装ruby
注意:请不要用rvm安装ruby,否则,后续会出现一些难以解决的问题
Gitlab7.x需要ruby2.x
如果系统自带的ruby版本低于2.x,就需要升级ruby
yum remove ruby
或者
cd
make uninstall
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz | tar xz
cd ruby-2.1.2
./configure --disable-install-rdoc
make
make prefix=/usr/local install
安装bundler
gem source-r https://rubygems.org/
gem source-a http://ruby.taobao.org/
gem install bundler --no-doc
四:系统配置
执行命令:visudo
把/usr/local/bin加入到secure_path里面去
然后,配置git用户可以使用sudo
如git ALL=(ALL) ALL
五:配置mysql
配置用户名,密码
创建数据库
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
注意:这里选择了mysql,则还需要安装mysql的开发包
Yum install mysql-devel
数据库如果选择的是pg,则也需要安装pg的开发包
五:配置redis
需要把redis.conf配置文件的
unixsocket/tmp/redis.sock
unixsocketperm777
这两项注释放开
Redis-serverredis.conf启动redis
执行chmod777 /tmp/redis.sock
六:安装gitlab(使用git用户)
1:
注意,这里必须用git clone下载(在git用户家目录下执行),不要下载网上已经打包好的tar.gz文件,否则以后不能升级
git clone https://gitlab.com/gitlab-org/gitlab-ce.git gitlab
cd /home/git/gitlab (注意目录位置,尽量使用默认的)
然后,切换到你需要安装的版本上
这里安装的是v7.9.2
gitcheckout v7.9.2(注意这里是tag)
gitcheckout -b gitlab-7-9-2
2:复制配置文件
cp config/gitlab.yml.example config/gitlab.yml
编辑config/gitlab.yml
修改host 为当前机器的ip地址
修改port为gitlab运行的端口地址,需要和下面的unicorn.rb配置的端口保持一致
cp config/unicorn.rb.example config/unicorn.rb
编辑config/unicorn.rb
把listen "127.0.0.1:8080"改成listen "8080"
cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
cp config/resque.yml.example config/resque.yml
修改config/resque.yml
把production的值改成:unix:/tmp/redis.sock
cp config/database.yml.mysql config/database.yml(请注意自己使用的数据库类型)
配置用户名,密码,数据库名称
3:授权目录
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
chmod -R u+rwX public/uploads
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
mkdir /home/git/gitlab-satellites
chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
mkdir tmp/backups
4:配置git
gitconfig --global user.name "GitLab"
gitconfig --global user.email "scm@xiangrikui.com"
gitconfig --global core.autocrlf input
5:修改Gemfile
vimGemfile
修改source为 http://ruby.taobao.org
加入下面的gem
gem 'therubyracer'
gem 'execjs'
注意:如果系统中安装了node.js,则不需要添加这2个gem
6:bundle install
bundle install --no-deployment --without development test postgres aws
中途如果不出意外的话,就安装完成(install中途可能要提示输入密码)
如果提示类似下面的错误:
An error occurred while installing ace-rails-ap (2.0.1), and Bundler cannot continue.
Make sure that `gem install ace-rails-ap -v '2.0.1'` succeeds before bundling.
类似这样的,需要手动安装的gem ,请手动安装,然后继续执行上面的bundle install
7:安装gitlab-shell(需要联网)
bundle exec rake gitlab:shell:install[v2.6.0] REDIS_URL=unix:/tmp/redis.sock
RAILS_ENV=production
chmod -R ug+rwX,o-rwx /home/git/repositories/
chmod -R ug-s /home/git/repositories/
find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s
注意,
这里的v2.6.0要和GITLAB_SHELL_VERSION文件里面的版本号保持一致
unix:/tmp/redis.sock要和redis.conf里面的配置unixsocket保持一致
8:初始化数据库
bundle exec rake gitlab:setup RAILS_ENV=production
成功的话,会输出
Administrator account created:
login.........admin@local.host
password......5iveL!fe
记住这里的用户名和密码
9:预编译
bundle exec rake assets:precompile RAILS_ENV=production
如果报了下面的错误
rake aborted!
Sprockets::FileNotFound: couldn't find file 'jquery.ui.all'
(in /home/git/gitlab/app/assets/javascripts/application.js.coffee:8)
则,需要修改Gemfile
gem "jquery-ui-rails"
改成
gem "jquery-ui-rails", “4.0.2”
然后,重新执行上面的bundle install
10:拷贝启动脚本
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
然后通过/etc/init.d/gitlab start,stop,restart启动,关闭gitlab
11:验证
启动服务:/etc/init.d/gitlab start
观察/home/git/gitlab/log目录的日志,
bundle exec rake gitlab:check RAILS_ENV=production
修复这里输出的错误信息
12:登陆系统
输入ip和端口访问系统
用上面的用户名和密码登陆系统
然后,修改密码
管理gitlab
一:gitlab的备份与恢复
备份:bundleexec rake gitlab:backup:create RAILS_ENV=production
还原:bundleexec rake gitlab:backup:restore RAILS_ENV=production
二:gitlab的升级
升级的思路一般是:
(1)备份
(2)升级ruby
(3)gitpull(获取最新的gitlab源代码,所以说安装的时候,就要用git获取源代码)
(4)执行一些其他的配置
评论暂时关闭