転載・引用について

ユーザ用ツール

サイト用ツール


tweet:2016:0212_03

FreeBSD 10.2にRedmineを投入

さて、これでrbenvも設定し、Rubyも2.3が動くようになったので、やっとRedmine 3.2のInstallへ。

  1. まず、必要そうなものを入れておく。
  2. Redmineを実行するアカウントを作る
    • ここでは、redmineとする
  3. Redmineを/usr/local/wwwに入れる
    • mkdir /usr/local/www
    • cd /usr/local/www
    • tar xzf redmine-3.2.0.tar.gz
    • ln -s redmine-3.2.0 redmine
  4. Redmineの初期設定を行う
    • cp redmine/config/database.yml.example redmine/config/database.yml
    • vi redmine/config/database.yml
      • 書き換えるのは、productionの部分だけで良い
    • production:
        adapter: mysql2
        database: redminedb
        host: xxx.xxx.xxx.xxx
        username: redmine_user
        password: "UltraSecret"
        encoding: utf8
  5. RubyのGemを入れる
    • 今回はUnicornで動かすので、一手間かける。
      • vi redmine/Gemfile.local
        gem "unicorn"
    • bundle install –without development test postgresql sqlite
  6. Redmineの初期設定を実行
    • sudo -u redmine /bin/sh
    • bundle exec rake generate_secret_token
    • RAILS_ENV=production bundle exec rake db:migrate
    • RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data
  7. Webrickでの試験
    • Rails 4.2以降、Webrickで通信を待ち受ける場合、defaultではlocalhostしかListenしなくなった。
    • ruby bin/rails server webrick -e production -b xxx.xxx.xxx.xxx と-bを指定してやれば、その引数のアドレスでListenするようになる。
  8. NGiNXとUnicornの設定
    • /etc/rc.conf に nginx_enable=“YES”を追加
    • Unicornを設定
      • unicorn設定ファイル内after_fork内でuser,groupをredmine:redmineに設定しているので注意
      • ぐぐると、Process ownerのchown関係がちゃんと動かない(worker.userがなかった頃の)unicorn.rbが引っかかるので注意
      • vi redmine/config/unicorn.rb
        # cat config/unicorn.rb 
        # -*- coding: utf-8 -*-
        # Unicorn Configuration File for Redmine
        #       http://unicorn.bogomips.org/examples/unicorn.conf.rb
        
        $unicorn_user = "redmine"
        $unicorn_group = "redmine"
        
        @dir = "/home/www/rrrm.rusty-raven.net/redmine"
        working_directory @dir
        worker_processes 2
        
        listen "/var/run/unicorn_rrrm.sock", :backlog => 32
        # listen 8282, :tcp_nopush => true
        
        timeout 30
        
        pid "/var/run/unicorn.pid"
        stdout_path File.expand_path("log/unicorn.stdout.log", @dir)
        stderr_path File.expand_path("log/unicorn.stderr.log", @dir)
        
        preload_app true
        
        check_client_connection false
        
        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
        end
        
        
        after_fork do |server, worker|
          defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
          begin
            worker.user($unicorn_user,$unicorn_group)
          rescue => ex
            STDERR.puts "could not change user, oh well"
            STDERR.puts ex.to_s
            raise ex
          end
        end
        
        # 
      • sudo unicorn_rails -c config/unicorn.rb -E production -D でunicornが起動する。
    • NGiNXの設定
      • NGiNX.confを修正する
                upstream REDMINE {
                        server unix:/var/run/unicorn.sock;
                }
                server {
                        listen 80 sndbuf=16k
                        server_name     redmine.example.net;
                        location / {
                                proxy_pass                      http://REDMINE;
                        }
                }

これで、とりあえず、Redmineまでは動くはず。

このウェブサイトはクッキーを使用しています。 Webサイトを使用することで、あなたはあなたのコンピュータにクッキーを保存することに同意します。 また、あなたはあなたが私たちのプライバシーポリシーを読んで理解したことを認めます。 同意しない場合はウェブサイトを離れてください。クッキーに関する詳細情報
tweet/2016/0212_03.txt · 最終更新: 2017/02/15 13:37 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki