プロジェクト管理ツール(Redmine)のインストール
必要かもしれないパッケージのインストール
yumでインストール
[root@localhost ~]# yum install -y ImageMagick ImageMagick-devel ipa-pgothic-fonts
データベースの準備
redmine用のデータベースの作成
[root@localhost ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.14-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database redmine character set utf8; Query OK, 1 row affected (0.19 sec) mysql> grant all on redmine.* to redmine@"%" identified by 'password'; Query OK, 0 rows affected (0.15 sec) mysql> flush privileges; Query OK, 0 rows affected (0.05 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | redmine | +--------------------+ 4 rows in set (0.09 sec) mysql> quit Bye [root@localhost ~]#
Ruby
bundlerのインストール
[root@localhost ~]# source ~/.zshrc [root@localhost ~]# rbenv rehash [root@localhost ~]# gem install bundler --no-rdoc --no-ri
Redmineのインストール
redmineの取得
[root@localhost ~]# cd /tmp/ [root@localhost ~]# wget http://rubyforge.org/frs/download.php/77242/redmine-2.4.0.tar.gz [root@localhost ~]#
解凍して指定の場所へ配置
[root@localhost tmp]# tar zxf redmine-2.4.0.tar.gz [root@localhost tmp]# mv redmine-2.4.0 /var/lib/redmine [root@localhost tmp]#
解凍内容を確認
[root@localhost tmp]# cd /var/lib/redmine [root@localhost redmine]# ll 合計 76 -rw-rw-r-- 1 1000 1000 240 11月 17 20:27 2013 CONTRIBUTING.md -rw-rw-r-- 1 1000 1000 3281 11月 17 20:27 2013 Gemfile -rw-rw-r-- 1 1000 1000 205 11月 17 20:27 2013 README.rdoc -rw-rw-r-- 1 1000 1000 275 11月 17 20:27 2013 Rakefile drwxrwxr-x 7 1000 1000 4096 11月 17 20:26 2013 app drwxrwxr-x 5 1000 1000 4096 11月 17 20:26 2013 config -rw-rw-r-- 1 1000 1000 160 11月 17 20:27 2013 config.ru drwxrwxr-x 3 1000 1000 4096 11月 17 20:26 2013 db drwxrwxr-x 2 1000 1000 4096 11月 17 20:26 2013 doc drwxrwxr-x 5 1000 1000 4096 11月 17 20:26 2013 extra drwxrwxr-x 2 1000 1000 4096 11月 17 20:26 2013 files drwxrwxr-x 8 1000 1000 4096 11月 17 20:27 2013 lib drwxrwxr-x 2 1000 1000 4096 11月 17 20:26 2013 log drwxrwxr-x 2 1000 1000 4096 11月 17 20:26 2013 plugins drwxrwxr-x 7 1000 1000 4096 11月 17 20:27 2013 public drwxrwxr-x 2 1000 1000 4096 11月 17 20:26 2013 script drwxrwxr-x 9 1000 1000 4096 11月 17 20:26 2013 test drwxrwxr-x 8 1000 1000 4096 11月 17 20:26 2013 tmp drwxrwxr-x 2 1000 1000 4096 11月 17 20:26 2013 vendor [root@localhost redmine]#
データベースの設定ファイルを確認
[root@localhost redmine]# vim config/database.yml ---- production: adapter: mysql2 database: redmine host: localhost username: redmine password: password encoding: utf8 ----
メール送信などの設定
[root@localhost redmine]# vim config/configuration.yml ---- production: email_delivery: delivery_method: :smtp smtp_settings: address: "localhost" port: 25 domain: 'example.com' rmagick_font_path: /usr/share/fonts/ipa-pgothic/ipagp.ttf ----
※メールは別のメールサーバを経由するのでlocalhostのまま
Gemのインストール
[root@localhost redmine]# bundle install --without development test [root@localhost redmine]#
redmineのデータベース設定(マイグレーション処理)
[root@localhost redmine]# bundle exec rake generate_secret_token [root@localhost redmine]# RAILS_ENV=production bundle exec rake db:migrate [root@localhost redmine]# RAILS_ENV=production bundle exec rake redmine:load_default_data Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja [root@localhost redmine]#
テスト起動
[root@localhost redmine]# bundle exec script/rails server webrick -e production => Booting WEBrick => Rails 3.2.15 application starting in production on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server # Unicornをインストールする → Rubyでのアプリケーションサーバのよう # パッケージを設定 [root@localhost redmine]#
unicornの設定
パッケージを別途追加
[root@localhost redmine]# vim Gemfile.local ---- gem "unicorn" ----
bundle install
[root@localhost redmine]# bundle install [root@localhost redmine]#
設定ファイルを作成
[root@localhost redmine]# vim config/unicorn.rb ---- worker_processes 1 timeout 60 listen File.expand_path("tmp/sockets/unicorn.sock", ENV['RAILS_ROOT']) pid File.expand_path("tmp/pids/unicorn.pid", ENV['RAILS_ROOT']) preload_app true stderr_path File.expand_path("log/unicorn.stderr.log", ENV['RAILS_ROOT']) stdout_path File.expand_path("log/unicorn.stdout.log", ENV['RAILS_ROOT']) GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true before_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! old_pid = "#{server.config[:pid]}.oldbin" if old_pid != server.pid begin sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU Process.kill(sig, File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH end end sleep 1 end after_fork do |server, worker| defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end ----
Unicornの起動
[root@localhost redmine]# bundle exec unicorn_rails -c config/unicorn.rb -D -E production -p 6001 [root@localhost redmine]#
supervisordの設定
起動スクリプトを作成
[root@localhost redmine]# mkdir -p /var/www/tools/redmine [root@localhost redmine]# vim /var/www/tools/redmine/redmine.sh ---- #!/bin/sh export PATH="/root/.plenv/shims:/root/.plenv/bin:/root/.phpenv/shims:/root/.phpenv/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin" source /root/.zshrc rbenv rehash cd /var/lib/redmine BUNDLE=/root/.rbenv/shims/bundle ENV=production CONF=config/unicorn.rb exec $BUNDLE exec unicorn_rails -E $ENV -c $CONF -p 6001 ----
実行権限を設定
[root@localhost redmine]# chmod 755 /var/www/tools/redmine/redmine.sh [root@localhost redmine]#
supervisordの設定ファイルに追加
[root@localhost redmine]# mkdir -p /var/log/unicorn [root@localhost redmine]# vim /etc/supervisord.conf ---- [program:redmine] user=root command=/var/www/tools/redmine/redmine.sh redirect_stderr=true autostart=true autorestart=true stopsignal=QUIT stdout_logfile=/var/log/unicorn/stdout.log logfile_maxbytes=1MB ----
再起動
[root@localhost ~]# service supervisord restart
nginx
設定ファイルを用意
[root@localhost ~]# mkdir -p /var/log/nginx/dev.redmine.com [root@localhost ~]# vim /etc/nginx/conf.d/dev.redmine.com.conf ---- server { # ポート、サーバネーム listen 80; server_name dev.redmine.com; # アクセスログ、エラーログ access_log /var/log/nginx/dev.redmine.com/access.log main; error_log /var/log/nginx/dev.redmine.com/error.log; # プロキシ location / { proxy_pass http://127.0.0.1:6001; } # アクセスを制限する location ~ (\.htaccess|\.git|\.svn) { deny all; } # 文字コード charset utf-8; } ----
再起動
[root@localhost ~]# service nginx restart
権限変更
[root@localhost ~]# cd /var/lib/redmine/ [root@localhost redmine]# chown -R nginx:nginx * [root@localhost redmine]# chmod -R 755 *
Redmine
最初はログイン、パスワードともadminでアクセスできる
ホスト名が「localhost:3000」とかになっているのでホストしたドメインを設定すること
表示デザインを変更
認証はメールにて認証する(毎回DBにアクセスして認証するの面倒なんで)
登録する機能
まとめ
なんとかなったけど、結構面倒なのでインストールには気をつける必要がある。