# modify install script
curl https://raw.github.com/jbhannah/gitlab-installer/master/gitlab-install-el6.sh > gitlab-install-el6.sh
chmod 744 gitlab-install-el6.sh
sed -i "s/https:\/\/raw\.github\.com\/gitlabhq\/gitlab-recipes\/master\/apache\/gitlab/https:\/\/raw\.github\.com\/gitlabhq\/gitlab-recipes\/master\/web-server\/apache\/gitlab\.conf/g" gitlab-install-el6.sh
sed -i "s/https:\/\/raw\.github\.com\/gitlabhq\/gitlabhq\/master\/lib\/support\/init.d\/gitlab/https:\/\/raw\.github\.com\/gitlabhq\/gitlab-recipes\/master\/init\/sysvinit\/centos\/gitlab-unicorn/g" gitlab-install-el6.sh
sed -i "s/GL_GIT_BRANCH=\"6-0-stable\"/GL_GIT_BRANCH=\"6-2-stable\"/g" gitlab-install-el6.sh
# run install script
./gitlab-install-el6.sh
# `Could not reliably determine the server’s fully qualified domain name`対策
grep -q 'ServerName localhost:80' /etc/httpd/conf/httpd.conf || echo 'ServerName localhost:80' >> /etc/httpd/conf/httpd.conf
# makr log directory
mkdir /var/log/httpd/logs
service httpd start
# timezone setting.
# vi /etc/sysconfig/clock
grep -q 'ZONE="Asia/Tokyo"' /etc/sysconfig/clock || echo 'ZONE="Asia/Tokyo"' >> /etc/sysconfig/clock
grep -q 'UTC="false"' /etc/sysconfig/clock || echo 'ZONE="UTC="false"' >> /etc/sysconfig/clock
source /etc/sysconfig/clock # apply
# overwrite timezone file
cp -p /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
-
以前試したときは動作がおかしかったが、gitlabサービスの起動スクリプトが更新されたため、正常動作するようになった
-
ホスト名の解決エラーになる場合は以下を実行
# ホスト名の解決のエラーになるので、hostsに追記 yum -y install bind-utils # vi /etc/hosts 103.245.222.133 raw.github.com 54.245.255.174 rubygems.org 97.107.133.48 get.rvm.io
# vi /home/git/gitlab-shell/config.yml
- gitlab_url: "http://localhost/"
+ gitlab_url: "http://localhost/gitlab/"
# vi /home/git/gitlab/config/gitlab.yml
- # relative_url_root: /gitlab
+ relative_url_root: /gitlab
# vi /home/git/gitlab/config/application.rb
- # config.relative_url_root = "/gitlab"
+ config.relative_url_root = "/gitlab"
# vi /home/git/gitlab/config/unicorn.rb
+ ENV['RAILS_RELATIVE_URL_ROOT'] = '/gitlab'
# 参考: http://stackoverflow.com/questions/17924644/gitlab-in-a-subdirectory-with-apache-and-passenger
# vi /etc/httpd/conf.d/gitlab.conf
RewriteCond /%{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond /gitlab/%{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/gitlab/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
# DocumentRoot /home/git/gitlab/public
RailsBaseURI /gitlab
- 参考: https://groups.google.com/forum/#!topic/gitlabhq/uayr5ksQ2c4
- 参考: http://www.dlrowb.com/blog/?p=30
-
参考: alminium: https://github.com/alminium/alminium
-
参考: Redmine 2.3をCentOS 6.4にインストールする手順http://blog.redmine.jp/articles/2_3/installation_centos/
-
ruby 2.0.0未対応とあるが、現状の最新版はサポート済み
# 必要なモジュールのインストール rpm -Uvh epel-release http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum -y groupinstall "Development Tools" yum -y install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel yum -y install mysql-server mysql-devel yum -y install httpd httpd-devel yum -y install ImageMagick ImageMagick-devel yum -y install ipa-pgothic-fonts # ruby, bundlerインストールスキップ # MySQLの設定 # vi /etc/my.cnf [mysqld] #... character-set-server=utf8 #... [mysql] default-character-set=utf8 # MySQL再起動 service mysqld restart # Redmine用データベースとユーザーの作成 ## rootのパスワード変更などはスキップ # mysql -uroot create database db_redmine default character set utf8; grant all on db_redmine.* to 'user_redmine@localhost' identified by 'redmine'; -- redmineは任意のパスワードへ flush privileges; exit; # Redmineのインストール svn co http://svn.redmine.org/redmine/branches/2.3-stable /var/lib/redmine # Redmineの設定 # vi /var/lib/redmine/config/database.yml production: adapter: mysql2 database: db_redmine host: localhost username: user_redmine password: redmine # redmineはmysqlに設定したパスワード encoding: utf8 ## 設定ファイル config/configuration.yml の作成 cp config/configuration.yml.example config/configuration.yml ## cp config/configuration.yml # Gemパッケージのインストール bundle install # Redmineの初期設定とデータベースのテーブル作成 bundle exec rake generate_secret_token RAILS_ENV=production bundle exec rake db:migrate chown -R apache:apache /var/lib/redmine # Passengerのインストール gem install passenger --no-rdoc --no-ri passenger-install-apache2-module # Passengerの設定 # vi /etc/httpd/conf.d/passenger.conf # Passengerの基本設定。 # passenger-install-apache2-module --snippet を実行して表示される設定を使用。 # 環境によって設定値が異なりますので以下の3行はそのまま転記しないでください。 # LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.21/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.21 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby # Passengerが追加するHTTPヘッダを削除するための設定(任意)。 # Header always unset "X-Powered-By" Header always unset "X-Rack-Cache" Header always unset "X-Content-Digest" Header always unset "X-Runtime" # 必要に応じてPassengerのチューニングのための設定を追加(任意)。 # 詳しくはPhusion Passenger users guide(http://www.modrails.com/documentation/Users%20guide%20Apache.html)をご覧ください。 PassengerMaxPoolSize 20 PassengerMaxInstancesPerApp 4 PassengerPoolIdleTime 3600 PassengerHighPerformance on PassengerStatThrottleRate 10 PassengerSpawnMethod smart RailsAppSpawnerIdleTime 86400 RailsFrameworkSpawnerIdleTime 0 RackBaseURI /redmine # Apacheの設定(/redmineサブディレクトリでredmineを動作させる) ln -s /var/lib/redmine/public /var/www/html/redmine # Apacheの再起動 service httpd restart
-
RedmineにOmniAuthインストール
cd /var/lib/redmine/plugins git clone git://github.com/suer/redmine_oauth_provider.git cd .. # vi config/application.rb require 'oauth/rack/oauth_filter' # ... config.middleware.use OAuth::Rack::OAuthFilter bundle install RAILS_ENV=production rake redmine:plugins:migrate NAME=redmine_oauth_provider service httpd restart # http://localhost:10080/redmine/oauth_clients/ にてOAuthのアプリ登録が行えるようになる(設定メニューなどからのリンクはない模様
-
参考: Gitlab, AsakusaSatellite などの開発者向け Rails アプリを Redmine で OAuth 認証するための Omniauth プラグイン作った
# vi /home/git/gitlab/Gemfile
gem 'omniauth-github'
+gem 'omniauth-redmine', :github => 'suer/omniauth-redmine'
cd /home/git/gitlab
bundle install --no-deployment # TODO: --no-deploymentなぜ必要なのか調査
omniauth:
# Allow login via Twitter, Google, etc. using OmniAuth providers
- enabled: false
+ enabled: true
- allow_single_sign_on: false
+ allow_single_sign_on: true
- block_auto_created_users: true
+ block_auto_created_users: false
# ..
providers:
+ - { name: 'redmine', app_id: 'uj6p1YSw5p0zMWK172NMsx32ToPNScIdepmrtKmL',
app_secret: 'vSXUAmfwsG991yJuiFVzlXIED6HZc0CSUTZS573B',
args: { redmine_base_url: 'http://localhost/redmine/' }}
service httpd restart
- 注意点
- redmineに登録するIDの名前にはアルファベット・数字・起動(-_.)のみしか使用できない
- 参考:Gitlab, AsakusaSatellite などの開発者向け Rails アプリを Redmine で OAuth 認証するための Omniauth プラグイン作った - すえひろがりっっっっ!
# vi /home/git/gitlab/config/gitlab.yml
## External issues trackers
issues_tracker:
redmine:
- project_url: "http://redmine.sample/projects/:issues_tracker_id"
+ project_url: "http://localhost/redmine/projects/:issues_tracker_id"
- issues_url: "http://redmine.sample/issues/:id"
+ issues_url: "http://localhost/redmine/issues/:id"
- new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new"
+ new_issue_url: "http://localhost/redmine/projects/:issues_tracker_id/issues/new"
service httpd restart
-
プロジェクトを作成(hiroakiユーザを利用して、test-hiroaki)
git@localhost:hiroaki256/test-hiroaki.git
-
Gitlab上にredmineユーザを追加
-
GitLabのプロジェクトのメンバーにredmineユーザーをReporterとして追加
-
Repoter用のSSH keyを追加
# キー作成 ssh-keygen -t rsa -C "hiroaki256+redmine@gmail.com" # キーを確認しGitLabの「Profile Settings」->「SSH Keys」に追加する less ~/.ssh/id_rsa.pub
-
ミラーリポジトリの作成
mkdir /var/lib/git_repositories cd /var/lib/git_repositories git clone --mirror git@localhost:hiroaki256/test-hiroaki.git chown apache:apahce * -R
-
Redmineのプロジェクト設定のリポジトリに登録(ローカルパスを指定)
/var/lib/git_repositories/test-hiroaki.git
-
GitLab上のWebHooksに登録し、commitのタイミングでミラーリポジトリを更新させる。
-
Redmineにredmine_github_hookをインストール
cd /var/lib/redmine/ gem install json cd /var/lib/redmine/plugins/ git clone https://github.com/koppen/redmine_github_hook.git cd .. rake redmine:plugins:migrate RAILS_ENV=production service httpd restart # うまくいかんな...
- 参考: GitLabとRedmine連携