UnicornとNginxによるRedmineの導入
【独立ブログは維持できず、ブログはここに移転した】
Redmineは、非常に使いやすいオープンソースプロジェクト管理システムです.会社の開発は基本的にPythonを使っていたので、トラクを選びました.少し前にRailsに触れてみたところ、Railsの配置も簡単だったので、涎を垂らしていたRedmineを試してみました.
本稿ではUnicornとNginxの導入方式に注目し,添付ファイルはapache+passenger方式の最初の導入である.
ruby環境のインストール
1、以下はUbuntuが提供したインストールパッケージでRubyをインストールします.使用をお勧めしません.製品環境ではここを見るべきです.
2、rubyとgemのバージョンを比較するとRedmineの要件を満たす.
3、gemのデフォルトソースをtaobaoが提供するRubyGemsミラーに設定し、国内訪問RubyGemsの公式ソースの不安定による影響を取り除く.
MySQLのインストールと構成
Redmineのユーザーとデータベースを作成するには、次の手順に従います.
Redmine依存のダウンロードとインストール
1、Redmineのダウンロードは、/opt/redmineなどのターゲットパスの下に解凍される.
2、redmineのgemソースもtaobaoの:Gemfileの内容を直接変更すればいい.
3、ruby、rails依存をインストールする
4、Redmineディレクトリに入り、bundleでRedmine依存をインストールする:
次のエラーが発生した場合は、libmysqlclient-devとlibmysql-rubyをインストールする必要があります.
Redmineの構成
1、データベースプロファイル:config/database.yml.config/database.yml.exampleは直接コピーして、直接編集します.注意:adapterがmysqlを選択するかmysql 2を選択するかは、プロファイルの上部の説明に基づいて決定されます.
2、初期化構成とデータ:
3、Redmineの構成を作成する(Redmineにはデフォルトの構成があるため、このステップは必須ではありません):
4、実行してみてください.正常であれば、Redmineにアクセスできるはずです(デフォルトのユーザーとパスワードはadminです):
5、よく使うEmailの構成:
Unicornのインストール
1.Gemfileを編集し、unicorn依存度を増加する:
2、unicornのインストール:
3、unicorn構成の作成:vi config/unicorn.rb、内容は以下の通りである.
4、unicorn_を実行するrails:
Nginxの設定
1、redmineパブリックディレクトリの権限を設定する:files/log/tmp/public/
2、構成Nginx:
3、Nginxを再起動する
使用開始
Redmineを導入した後、管理者は、サイト名、welcome情報、会社ロゴ、匿名ユーザーにコンテンツが表示されない、Emailなどの基本的な設定を行う必要があります.
注意しなければならないのは、Email設定の場合、プロファイルを変更して再起動した後、adminがシステム設定でfromのメールアドレスを再設定し、記入した後、ページ右下隅にテストの接続がある(これはあまり探しにくい)ことです.Redmineのメールの注意は称賛に値して、それはユーザーレベルの5の中で異なる選択を提供しました:すべてを受信して、私に関連するだけを受信して、私に作成して、私に割り当てて、完全に受信しません.トラックに比べて人間的になった.
Redmineのもう一つの素晴らしいところは、システムの外観を変更しやすく、オープンソースできれいなthemeがたくさんあります. 37 Signalからのきれいなテーマ 公式テーマリスト
参照1:Railsの一般的な導入方法の紹介
参考2:Redmine公式配置WIFI
Redmineは、非常に使いやすいオープンソースプロジェクト管理システムです.会社の開発は基本的にPythonを使っていたので、トラクを選びました.少し前にRailsに触れてみたところ、Railsの配置も簡単だったので、涎を垂らしていたRedmineを試してみました.
本稿ではUnicornとNginxの導入方式に注目し,添付ファイルはapache+passenger方式の最初の導入である.
ruby環境のインストール
1、以下はUbuntuが提供したインストールパッケージでRubyをインストールします.使用をお勧めしません.製品環境ではここを見るべきです.
apt-get install ruby rubygems
2、rubyとgemのバージョンを比較するとRedmineの要件を満たす.
ruby -v
gem -v
3、gemのデフォルトソースをtaobaoが提供するRubyGemsミラーに設定し、国内訪問RubyGemsの公式ソースの不安定による影響を取り除く.
gem source --list
gem source -r https://rubygems.org/
gem source -a http://ruby.taobao.org
bundler
gem install bundler
MySQLのインストールと構成
Redmineのユーザーとデータベースを作成するには、次の手順に従います.
CREATE DATABASE redmine DEFAULT CHARACTER SET utf8;
GRANT ALL ON redmine.* TO redmine@localhost IDENTIFIED BY 'redmine' WITH GRANT OPTION;
Redmine依存のダウンロードとインストール
1、Redmineのダウンロードは、/opt/redmineなどのターゲットパスの下に解凍される.
2、redmineのgemソースもtaobaoの:Gemfileの内容を直接変更すればいい.
3、ruby、rails依存をインストールする
apt-get install libruby ruby-dev libmagickcore-dev libmagickwand-dev libmysqlclient-dev libmysql-ruby
4、Redmineディレクトリに入り、bundleでRedmine依存をインストールする:
bundle install --without development test postgresql sqlite rmagick
次のエラーが発生した場合は、libmysqlclient-devとlibmysql-rubyをインストールする必要があります.
Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
An error occurred while installing mysql (2.8.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.8.1'` succeeds before bundling.
Redmineの構成
1、データベースプロファイル:config/database.yml.config/database.yml.exampleは直接コピーして、直接編集します.注意:adapterがmysqlを選択するかmysql 2を選択するかは、プロファイルの上部の説明に基づいて決定されます.
2、初期化構成とデータ:
rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
3、Redmineの構成を作成する(Redmineにはデフォルトの構成があるため、このステップは必須ではありません):
cp config/configuration.yml.example config/configuration.yml
4、実行してみてください.正常であれば、Redmineにアクセスできるはずです(デフォルトのユーザーとパスワードはadminです):
ruby script/rails server webrick -e production (redmine3 rails )
5、よく使うEmailの構成:
### qq exmail
email_delivery:
delivery_method: :async_smtp
async_smtp_settings:
address: smtp.exmail.qq.com
port: 25
domain: exmail.qq.com
authentication: :login
user_name: "[email protected]"
password: "xxx"
###Gmail
email_delivery:
delivery_method: :async_smtp
async_smtp_settings:
address: "smtp.gmail.com"
port: 587
domain: "smtp.gmail.com"
authentication: :login
user_name: "[email protected]"
password: "xxx"
Unicornのインストール
1.Gemfileを編集し、unicorn依存度を増加する:
gem "unicorn"
2、unicornのインストール:
gem install unicorn
3、unicorn構成の作成:vi config/unicorn.rb、内容は以下の通りである.
app_path = "/opt/redmine"
worker_processes 2
working_directory = app_path
listen app_path + "/tmp/sockets/unicorn.sock", :backlog => 64
listen "127.0.0.1:8082", :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
# feel free to point this anywhere accessible on the filesystem
pid app_path + "/tmp/pids/unicorn.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path app_path + "/log/unicorn.stderr.log"
stdout_path app_path + "/log/unicorn.stdout.log"
# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
check_client_connection false
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# The following is only recommended for memory/DB-constrained
# installations. It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# # This allows a new master process to incrementally
# # phase out the old master process with SIGTTOU to avoid a
# # thundering herd (especially in the "preload_app false" case)
# # when doing a transparent upgrade. The last worker spawned
# # will then kill off the old master process with a SIGQUIT.
# 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
#
# Throttle the master from forking too quickly by sleeping. Due
# to the implementation of standard Unix signal handlers, this
# helps (but does not completely) prevent identical, repeated signals
# from being lost when the receiving process is busy.
# sleep 1
end
after_fork do |server, worker|
# per-process listener ports for debugging/admin/migrations
# addr = "127.0.0.1:#{9293 + worker.nr}"
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
# if preload_app is true, then you may also want to check and
# restart any other shared sockets/descriptors such as Memcached,
# and Redis. TokyoCabinet file handles are safe to reuse
# between any number of forked children (assuming your kernel
# correctly implements pread()/pwrite() system calls)
end
4、unicorn_を実行するrails:
RAILS_ENV=production unicorn_rails -c config/unicorn.rb -E prodcution -D
Nginxの設定
1、redmineパブリックディレクトリの権限を設定する:files/log/tmp/public/
2、構成Nginx:
upstream redmine_backend {
server unix:/opt/redmine/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80; ## listen for ipv4; this line is default and implied
server_name redmine.h7sc.com red.man1dian.com;
keepalive_timeout 5;
root /opt/redmine/public;
access_log /var/log/nginx/redmine-access.log ;
error_log /var/log/nginx/redmine-error.log ;
location ~* ^/(images|javascripts|stylesheets|img)/ {
access_log off;
log_not_found off;
expires max;
break;
}
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering on;
if (!-f $request_filename) {
proxy_pass http://redmine_backend;
break;
}
}
}
3、Nginxを再起動する
使用開始
Redmineを導入した後、管理者は、サイト名、welcome情報、会社ロゴ、匿名ユーザーにコンテンツが表示されない、Emailなどの基本的な設定を行う必要があります.
注意しなければならないのは、Email設定の場合、プロファイルを変更して再起動した後、adminがシステム設定でfromのメールアドレスを再設定し、記入した後、ページ右下隅にテストの接続がある(これはあまり探しにくい)ことです.Redmineのメールの注意は称賛に値して、それはユーザーレベルの5の中で異なる選択を提供しました:すべてを受信して、私に関連するだけを受信して、私に作成して、私に割り当てて、完全に受信しません.トラックに比べて人間的になった.
Redmineのもう一つの素晴らしいところは、システムの外観を変更しやすく、オープンソースできれいなthemeがたくさんあります.
参照1:Railsの一般的な導入方法の紹介
参考2:Redmine公式配置WIFI