安装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/
安装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
使用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' IDENTIFIED BY 'gitpasswd';
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.*TO 'gituser'@'localhost';
\q
# 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
安装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
如出现此类错误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
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
初始化数据库
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
Do you want to continue (yes/no)? yes
初始化完成后最后两行就是你gitlab默认的用户名密码
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
}
更改权限及启动nginx
sudo nginx -t
sudo chown -R git.git /var/lib/nginx/
sudo /etc/init.d/nginx start