===============================
Requirements
- CentOS (Tested on 6.5)
- ruby (Tested on 1.9.3)
Install
- epelレポジトリをインストール
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- 依存パッケージをインストール
yum groupinstall 'Development Tools'
yum install vim-enhanced httpd readline readline-devel ncurses-devel gdbm-devel glibc-devel \
tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc \
sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel \
libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel \
python-devel redis sudo mysql-server wget \
mysql-devel crontabs logwatch logrotate \
perl-Time-HiRes
- gitlabが使用するユーザを作成
adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git git
- gitユーザにシングルモードでrvmをインストール
su - git
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
su - git
rvm install 1.9.3
- mysqlにgitlab用ユーザ・テーブルを作成
mysql -u root
CREATE USER gitlabhq@localhost IDENTIFIED BY 'password';
CREATE DATABASE gitlabhq_production;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO gitlabhq@localhost;
- redisを起動
chkconfig redis on
service redis start
- gitユーザの設定
su - git
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
git config --global user.name "GitLab"
git config --global user.email "gitlab@example.com"
- gitlab-shellをインストール
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
git checkout -b v1.1.0 v1.1.0
cp config.yml.example config.yml
sed -i 's|http://localhost/|http://localhost:3000/|' config.yml
diff -u config.yml.example config.yml
./bin/install
対象バージョンにcheckout
cd ~
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd gitlab
git checkout 46063803162064e05973c6c86e7033801266c34c
- gitlabの設定
cp config/gitlab.yml.example config/gitlab.yml
vi config/gitlab.yml
diff -u config/gitlab.yml.example config/gitlab.yml
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
cp config/unicorn.rb.example config/unicorn.rb
sed -i config/unicorn.rb -e '/^listen/{
a listen 3000
s/^listen/#listen/
}'
cp config/database.yml.mysql config/database.yml
vi config/database.yml
GemfileとGemfile.lockを書き換え
Gemfile:136
- gem "modernizr", "2.6.2"
+ gem "modernizr-rails", "2.7.1"
Gemfile.lock:286
- modernizr (2.6.2)
+ modernizr-rails (2.7.1)
Gemfile.lock:600
- modernizr (= 2.6.2)
+ modernizr-rails (= 2.7.1)
- gitlabインストール
cd ~
mkdir gitlab-satellites
cd gitlab
bundle install --deployment --without development test postgres
sudo service mysqld start
bundle exec rake gitlab:setup RAILS_ENV=production
- initスクリプトの作成
curl --output /etc/init.d/gitlab https://raw.githubusercontent.com/gitlabhq/gitlab-recipes/5-0-stable/init.d/gitlab-centos
sed -i -e "s/USER\=\$NAME/USER=git/g" /etc/init.d/gitlab
sed -i -e "s#\(RUBY\_PATH\_PATCH\=\"PATH\=\$PATH\:\)\(.*$\)#\1/usr/local/rvm/gems/ruby-1.9.3-p547/bin:/usr/local/rvm/gems/ruby-1.9.3-p547@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p547/bin:\2#g" /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab
chkconfig --add gitlab
- 正常にインストールされたかチェック
bundle exec rake gitlab:env:info RAILS_ENV=production
- gitlab起動
service gitlab start
- アクセスし確認
http://local.gitlab.com:3000/
user: admin@local.host
pass: 5iveL!fe
- 5.0はバックアップリストア用のコマンドにバグがあるのでパッチを当てる
hoge.patch
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -157,8 +157,8 @@ namespace :gitlab do
# Build a backup path
path_to_bundle = File.join(backup_path_repo, project.path_with_namespace + ".bundle")
-
- if Kernel.system("git clone --bare #{path_to_bundle} #{project.repository.path_to_repo} > /dev/null 2>&1")
+ path_to_repo = File.join(repos_path, project.path_with_namespace + ".git")
+ if Kernel.system("git clone --bare #{path_to_bundle} #{path_to_repo} > /dev/null 2>&1")
puts "[DONE]".green
else
puts "[FAILED]".red
patch lib/tasks/gitlab/backup.rake < hoge.patch
- バックアップ作成
bundle exec rake gitlab:satellites:create RAILS_ENV=production
- リストア
bundle exec rake RAILS_ENV=production gitlab:backup:restore BACKUP=
Trouble shooting
- ログを確認して何が起こっているか確認
cd /home/git/gitlab/log
tail -f *.log
- cloneやpullをしようとすると
git
ユーザの認証が走りgitlab-shellが失敗する
gitlab-shell
の設定に誤りがあります。gilab-shell
ディレクトリのconfig.yml
やlib/gitlab_config.rb
のgitlab_url
が正しいホストとポートになってるか確認しましょう。
config.yml
-gitlab_url: "https://localhost/"
+gitlab_url: "https://gitlab.example.com/"
lib/gitlab_config.rb
-@config['gitlab_url'] ||= "http://localhost/"
+@config['gitlab_url'] ||= "https://gitlab.example.com/"