Redmine

提供: ArchWiki
2016年6月26日 (日) 20:12時点におけるKusakata (トーク | 投稿記録)による版 (ページの作成:「Category:バージョン管理システム en:Redmine {{Related articles start}} {{Related|Ruby on Rails}} {{Related|RVM}} {{Related|MariaDB}} {{Related|Apache}}...」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

関連記事

Redmineフリーかつオープンソースの、ウェブベースのプロジェクト管理課題管理ツールです。複数のプロジェクト・サブプロジェクトを扱うことができます。機能 としてプロジェクト wiki やフォーラム、時間管理、柔軟なロールベースのアクセス制御があります。カレンダーガントチャートも搭載しており、プロジェクトのデッドラインを視覚的に把握できます。Redmine は様々なバージョン管理システムと統合できるように、リポジトリブラウザや差分ビューアを内蔵しています。

Redmine は Ruby on Rails フレームワークを使用して書かれています。クロスプラットフォームで動作し、複数のデータベースと34もの言語をサポートしています。

要件

このドキュメントでは Redmine のインストール手順をガイドするにあたって、Redmine を使うのに必要なソフトウェアも一緒に説明します。しかしながら、Redmine と依存パッケージを別々にインストールすることも可能です。その場合は下のセクションを参照してください。

ここではインストール手順を全て説明しますが、必ずしもこの方法しかないというわけではありません。Redmine が必要とするソフトウェアには様々な選択肢が考えられます。例えば、データベースには mariaDB, mySQL, postgreSQL などがあります。

ノート: This guide is a default suggestion, feel free to substitute any of the prerequisites mentioned on this page.

Ruby

Redmine バージョン サポートされている Ruby バージョン 使用する Rails バージョン
3.0.2 ruby 1.9.33, 2.0.02, 2.1, 2.21 Rails 4.20

Ruby をインストールする方法は2つ存在します: Ruby のページに書かれているように ruby パッケージをインストールする方法と RVM のページに書かれているように RVM をインストールする方法です (後者が推奨されています)。

ノート:
警告: If you use RVM, pay attention to the single and multiple user differences! If you are not creating a hosting service, the multiple user (available for all users on the machine) should be the choice for simpler debuging.

データベース

Redmine は 多数のデータベース に対応しています。

MariaDB 5.0 以上 (推奨)

MariaDB は MySQL のフォークでありバイナリ互換性が保たれています。また、Arch Linux における MySQL のデフォルト実装 でもあります。

mariadb のインストールについては MySQL を参照してください。

MySQL 5.0 以上

Oracle MySQLAUR に移動しました。

AURmysqlAUR パッケージをインストールしてください。

PostgreSQL 8.2 以上

postgresql のインストールについては PostgreSQL を参照してください。

データベースのデータ形式は ISO に設定してください (PostgreSQL のデフォルト設定)。次のコマンドで設定できます:

ALTER DATABASE "redmine_db" SET datestyle="ISO,MDY";
ノート: PostgreSQL 8.4.0 と 8.4.1 には Redmine に影響を与えるバグが存在します (#4259, #4314)。バグは PostgreSQL 8.4.2 で修正されました。

Microsoft SQL Server

警告: Support is temporarily broken (with ruby 2.0.0 under Windows because of database adapter gem incompatibility).

SQLite 3

本番環境におけるマルチユーザーはサポートされていません。そのため Redmine で使うためにインストール・設定する方法は説明しません。詳しくは 上流のドキュメント を参照。

ウェブサーバー

Apache

apache のインストールについては Apache を参照してください。

Unicorn

Unicorn サーバーのインストール (ruby gem) については Ruby on Rails#Unicorn を参照してください。

Nginx

nginx のインストールについては Nginx を参照してください。

Apache Tomcat

tomcat6tomcat7 のインストールについては Tomcat を参照してください。

オプション

SCM (Source Code Management)

SCM サポートされているバージョン 注記
Git >=1.5.4.2
Subversion 1.3, 1.4, 1.5, 1.6 & 1.7 1.3 以上が必要です。
Subversion の Ruby バインディングはサポートされません。
Subversion 1.7.0 と 1.7.1 にはバグが存在します #9541
Mercurial >=1.6 バージョン 1.6 未満のサポートは外されました #9465
Bazaar >= 2.0.4
Darcs >=1.0.7
CVS 1.12.12 1.12 が必要。
CVSNT では動作しません。

詳細は Redmine Repositories Wiki を参照。

ImageMagick (推奨)

ガントチャートを PNG ファイルにエクスポートするには ImageMagick が必要です。

imagemagick をインストールするには:

# pacman -S imagemagick

Ruby OpenID ライブラリ

OpenID のサポートを有効にするには、Ruby の OpenID ライブラリのバージョン2以上が必要です。

インストール

ビルドとインストール

AUR から redmineAUR パッケージをダウンロード・ビルド・インストールしてください。

ノート: ビルド方法はパッケージのビルドに書かれています。AUR のページを読むことを強く推奨します。

データベースの設定

次に、Redmine がデータを保存するのに使用するデータベースを作成します。以下、データベースとそのユーザーの名前を redmine とします。適宜置き換えてください。

ノート: MariaDBMySQL はバイナリ互換性があるため設定も同じです。

データベースの作成

データベースとユーザーを作成して権限を設定 (MariaDB と MySQL >= 5.0.2):

# mysql -u root -p
CREATE DATABASE redmine CHARACTER SET UTF8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';

5.0.2 以前のバージョンの MariaDB と MySQL の場合:

# mysql -u root -p
CREATE DATABASE redmine CHARACTER SET UTF8;
GRANT ALL PRIVILEGES ON redmine.* TO'redmine'@'localhost' IDENTIFIED BY 'my_password';

PostgreSQL の場合:

CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'my_password' NOINHERIT VALID UNTIL 'infinity';
CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;

SQLServer の場合:

SQL Server Management Studio の中でデータベースやユーザーを作成することもできますが、SQLCMD でコマンドラインを使うこともできます:

USE [master]
GO
-- Very basic DB creation
CREATE DATABASE [REDMINE]
GO
-- Creation of a login with SQL Server login/password authentication and no password expiration policy
CREATE LOGIN [REDMINE] WITH PASSWORD=N'redminepassword', DEFAULT_DATABASE=[REDMINE], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
-- User creation using previously created login authentication
USE [REDMINE]
GO
CREATE USER [REDMINE] FOR LOGIN [REDMINE]
GO
-- User permissions set via roles
EXEC sp_addrolemember N'db_datareader', N'REDMINE'
GO
EXEC sp_addrolemember N'db_datawriter', N'REDMINE'
GO
ノート: If you want to use additional environments, you must create separate databases for each one (for example: development and test).

データベースのアクセス設定

Now you need to configure Redmine to access the database we just created. To do that you have to copy /usr/share/webapps/redmine/config/database.yml.example to database.yml:

# cd /usr/share/webapps/redmine/config
# cp database.yml.example database.yml

And then edit this file in order to configure your database settings for "production" environment (you can configure for the "development" and "test" environments too, just change the appropriate sections).

Example for MariaDB and MySQL database:

nano database.yml
production:
  adapter: mysql2
  database: redmine
  host: localhost
  port: 3307   #If your server is not running on the standard port (3306), set it here, otherwise this line is unnecessary.
  username: redmine
  password: my_password
ノート: For ruby1.9 the "adapter" value must be set to mysql2, and for ruby1.8 or jruby, it must be set to mysql.

Example for PostgreSQL database:

nano database.yml
production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: redmine
  password: my_password
  encoding: utf8
  schema_search_path: <database_schema> (default - public)

Example for a SQL Server database:

nano database.yml
production:
  adapter: sqlserver
  database: redmine
  host: localhost #Set not default host (localhost) here, otherwise this line is unnecessary.
  port: 1433 #Set not standard port (1433) here, otherwise this line is unnecessary.
  username: redmine
  password: my_password

Ruby gem

Redmine requires some RubyGems to be installed and there are multiple ways of installing them (as listed on the referenced page).

  • prototype-rails
  • unicorn (an application-server)
  • mysql2 (high-performance Ruby bindings for MySQL)
  • coderay
  • erubis
  • fastercsv
  • rdoc
  • net-ldap
  • rack-openid

Obviously, if you choose a different database-server, or want to use a different application-server you should replace mysql2 and unicorn to your liking.

Adding Additional Gems (Optional)

If you need to load gems that are not required by Redmine core (eg. Puma, fcgi), create a file named Gemfile.local at the root of your redmine directory. It will be loaded automatically when running bundle install:

# nano Gemfile.local
gem 'puma'

Check previously installed gems

The Redmine devs included Bundler in Redmine, which can manage Gems just like pacman manages packages. Run the following command to assure that all Redmine dependencies are met:

# bundle install --without development test

This should output a list of gems Redmine needs.

Gem のインストール

ノート: If you prefer, you can install all the gems as pacman packages. You have only to search for the gem package and install them as usual. As of using Ruby gem is much simpler to manage and maintain up to date gems, this will be preferable and used as default bellow.

Redmine uses Bundler to manage gems dependencies. So, you need to install Bundler first:

# gem install bundler

Then you can install all the gems required by Redmine using the following command:

# cd /usr/share/webapps/redmine
# bundle install

To install without the ruby development and test environments use this instead of the last command:

# bundle install --without development test
ノート: You can include/exclude environments using the above syntax.

Although imagemagick is highly recommended, if you do not use it, you should skip the installation of the rmagick gem using:

# bundle install --without rmagick
ノート: Only the gems that are needed by the adapters you have specified in your database configuration file are actually installed (eg. if your config/database.yml uses the mysql2 adapter, then only the mysql2 gem will be installed). Do not forget to re-run bundle install when you change or add adapters in this file.

Session Store Secret Generation

Now you must generate a random key that will be used by Rails to encode cookies that stores session data thus preventing their tampering:

# bundle exec rake generate_secret_token
ノート: For Redmine prior to 2.x this step is done by executing # bundle exec rake generate_session_store.
警告: Generating a new secret token invalidates all existing sessions after restart.

Database Structure Creation

With the database created and the access configured for Redmine, now it is time to create the database structure. This is done by running the following command under the application root directory:

# cd /usr/share/webapps/redmine
# RAILS_ENV=production bundle exec rake db:migrate

These command will create tables by running all migrations one by one then create the set of the permissions and the application administrator account, named admin.

Database Population with Default Data

Now you may want to insert the default configuration data in database, like basic types of task, task states, groups, etc. To do so execute the following:

# RAILS_ENV=production bundle exec rake redmine:load_default_data

Redmine will prompt for the data set language that should be loaded; you can also define the REDMINE_LANG environment variable before running the command to a value which will be automatically and silently picked up by the task:

# RAILS_ENV=production REDMINE_LANG=pt-BR bundle exec rake redmine:load_default_data
ノート: This step is not mandatory, but it certainly will save you a lot of work to start using Redmine. And for a first time it can be very instructive.

ファイルシステムのパーミッション

The user account running the application must have write permission on the following subdirectories:

files: storage of attachments.
log: application log file production.log.
tmp and tmp/pdf: used to generate PDF documents among other things (create these ones if not present).

Assuming you run the application with a the default Apache user http account:

# mkdir tmp tmp/pdf public/plugin_assets
# chown -R http:http files log tmp public/plugin_assets
# chmod -R 755 files log tmp tmp/pdf public/plugin_assets

インストールのテスト

To test your new installation using WEBrick web server run the following in the Redmine folder:

# ruby bin/rails server webrick -e production

Once WEBrick has started, point your browser to http://localhost:3000/. You should now see the application welcome page. Use default administrator account to log in: admin/admin. You can go to Administration menu and choose Settings to modify most of the application settings.

警告: Webrick is not suitable for production use, please only use webrick for testing that the installation up to this point is functional. Use one of the many other guides in this wiki to setup redmine to use either Passenger (aka mod_rails), FCGI or a Rack server (Unicorn, Thin, Puma or hellip) to serve up your redmine.

プロダクションサーバーの設定

For Apache and Nginx, it is recommended to use Phusion Passenger. Passenger, also known as mod_rails, is a module available for Nginx and Apache.

Start by installing the 'passenger' gem:

# gem install passenger

Now you have to look at your passenger gem installation directory to continue. If you do not known where it is, type:

# gem env

And look at the GEM PATHS to find where the gems are installed. If you followed this guide and installed RVM, you can have more than one path, look at the one you are using.

For this guide so far, the gem path is /usr/local/rvm/gems/ruby-2.0.0-p247@global.

# cd /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/passenger-4.0.23

If you are aiming to use Apache, run:

# passenger-install-apache2-module

In case a rails application is deployed with a sub-URI, like http://example.com/yourapplication, some additional configuration is required, see the modrails documentation

For Nginx:

# passenger-install-nginx-module

And finally, the installer will provide you with further information regarding the installation (such as installing additional libraries). So, to setup your server, simply follow the output from the passenger installer.

アップデート

Redmine で使用しているファイルをバックアップ:

# tar czvf ~/redmine_files.tar.gz -C /usr/share/webapps/redmine/ files

Redmine にインストールしたプラグインをバックアップ:

# tar czvf ~/redmine_plugins.tar.gz -C /usr/share/webapps/redmine/ plugins

データベースをバックアップ:

# mysqldump -u root -p <redmine_database> | gzip > ~/redmine_db.sql.gz

普通にパッケージをアップデート (AUR):

# wget https://aur.archlinux.org/packages/re/redmine/redmine.tar.gz
# tar -zxpvf redmine.tar.gz
# cd redmine

ダウンロードしたファイルを確認して (特に PKGBUILD)、ビルド:

# makepkg -s
# pacman -U redmine-2.3.0-2-any.pkg.tar.gz
ノート: AUR のインストールやアップデートは AUR ヘルパーを使うことで簡単にできますが、サポートはされていません。

gem をアップデート:

# bundle update

For a clean gems environment, you may want to remove all the gems and reinstall them. To go through this, do:

# for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done
警告: The command above will delete ALL the gems in your system or user, depending of what type of Ruby installation you did in the prerequisites step. You must take care or you can stop working another applications that rely on Ruby gems.

If you did the last step and removed all the gems, now you will need to reinstall them all:

# gem install bundler
# bundle install --without development test
ノート: If you removed ALL the gems as above, and used a server that uses a gem, remember to reinstall the server gem: passenger (for Apache and Nginx), Mongrel or Unicorn. To do this, just follow the steps in the installation tutorial above.

Copy the saved files:

# tar xzvf ~/redmine_files.tar.gz -C /usr/share/webapps/redmine/

Copy the installed plugins

# tar xzvf ~/redmine_plugins.tar.gz -C /usr/share/webapps/redmine/

Regenerate the secret token:

# cd /usr/share/webapps/redmine
# bundle exec rake generate_secret_token

Check for any themes that you may have installed in the public/themes directory. You can copy them over but checking for updated version is ideal.

警告: Do NOT overwrite config/settings.yml with the old one.

Update the database. This step is the one that could change the contents of your database. Go to your new redmine directory, then migrate your database:

# RAILS_ENV=production REDMINE_LANG=pt-BR bundle exec rake db:migrate

If you have installed any plugins, you should also run their database migrations:

# RAILS_ENV=production REDMINE_LANG=pt-BR bundle exec rake redmine:plugins:migrate

Now, it is time to clean the cache and the existing sessions:

# RAILS_ENV=production bundle exec rake tmp:cache:clear tmp:sessions:clear

Restart the application server (e.g. puma, thin, passenger, etc). And finally go to "Admin -> Roles & permissions" to check/set permissions for the new features, if any.

トラブルシューティング

RMagick gem without support for High Dynamic Range in ImageMagick

As of ImageMagick 6.8.6.8-1, it is built with HDRI (High Dynamic Range Image) support, and this breaks the RMagick gem as seen in FS#36518.

The github rmagick is already patched, but the mantainer did not packed it for rubygems yet.

To install this patched version download the git repository:

# git clone https://github.com/rmagick/rmagick.git

Then, you need to build the gem:

# cd rmagick
# gem build rmagick.gemspec

And finally install it:

# gem install rmagick-2.13.2.gem
ノート: It will show some complains like unable to convert "\xE0" from ASCII-8BIT to UTF-8 for ext/RMagick/RMagick2.so, skipping, but you can safelly ignore it.

Runtime error complaining that RMagick was configured with older version

If you get the following runtime error after upgrading ImageMagick This installation of RMagick was configured with ImageMagick 6.8.7 but ImageMagick 6.8.8-1 is in use. then you only need to reinstall (or rebuild as shown above if is the case).

ノート: This is due to that when you install the RMagick gem it compiles some native extensions and they may need to be rebuilt after some ImageMagick upgrades.

OpenSSL error about "SSLv3_client"

After thel latest OpenSSL release (version 1.0.2.g-3) the ruby stop to work and you cannot build some ruby versions. You have two way to fix it:

1. Use ruby-head (if using RVM) or 2.3.0or above (if using arhc package).

2. Use this patch as noted in Issue 3529 and Issue 3548

# curl https://github.com/ruby/ruby/commit/801e1fe46d83c856844ba18ae4751478c59af0d1.diff > openssl.patch
# rvm install --patch ./openssl.patch 2.0.0 /*or another ruby version*/

Error when installing gems: Cannot load such file -- mysql2/mysql2

If you see an error like cannot load such file -- mysql2/mysql2, you are having a problem with the installation of the database gem. Probably a misconfiguration in the Database Access Configuration step. In this case you should verify the database.yml file.

If no success, you can manually install the database gem by:

# gem install mysql2

In last case, as suggested by Bobdog, you can try to comment the line of the database gem and add a new one as bellow:

<path-to-mysql2-gem-directory>/lib/mysql2/mysql2.rb
# require 'mysql2/mysql2'
require '<path-to-mysql2-gem-directory>/lib/mysql2/mysql2.so'

Apache 2.4 Updating

When updating to Apache 2.4 will be necessary to remove and install all your gems to make sure all of them that need to build native extensions will be rebuilt against the new Apache server.

So, for a clean gems environment, remove all the gems:

# for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done

To reinstall the gems:

# cd /usr/share/webapps/redmine
# gem install bundler
# bundle install --without development test

Remember to reinstall the RMagick gem as describe above in RMagick gem without support for High Dynamic Range in ImageMagick.

And if you are using Passenger to serve your apps through Apache you will need to reinstall it as described above in Configure the production server.

Checkout SVN Source

Get the Redmine source (Download instructions). Here is method of installing Redmine directly from subversion in /srv/http/redmine/

# useradd -d /srv/http/redmine -s /bin/false redmine
# mkdir -p /srv/http/redmine
# svn checkout http://svn.redmine.org/redmine/branches/2.1-stable /srv/http/redmine
# chown -R redmine: /srv/http/redmine

Automating The Update Process

Example of an after-update script:

#!/usr/bin/bash
export RAILS_ENV=production
grep -E "^gem 'thin'" Gemfile || echo "gem 'thin'" >> Gemfile
bundle update && bundle exec rake generate_secret_token db:migrate redmine:plugins:migrate tmp:cache:clear tmp:sessions:clear
ノート: Note that this script uses Thin as application server, so you must change it to your needs.

Systemd ユニットの作成

If you want to automatic run you application server when system starts, you need to create a systemd unit file.

ノート: This is not needed if you use apache or nginx with Passenger gem. Those servers already have their own unit file, so you have only to enable it.
/etc/systemd/system/redmine.service
[Unit]
Description=Redmine server
After=syslog.target
After=network.target

[Service]
Type=simple
User=redmine2
Group=redmine2
Environment=GEM_HOME=/home/redmine2/.gem/
ExecStart=/usr/bin/ruby /usr/share/webapps/redmine/script/rails server webrick -e production

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

Complaints about psych

Like that:

/usr/lib/ruby/2.1.0/psych/parser.rb:33:in `<class:Parser>': superclass mismatch for class Mark (TypeError)
from /usr/lib/ruby/2.1.0/psych/parser.rb:32:in `<module:Psych>'
from /usr/lib/ruby/2.1.0/psych/parser.rb:1:in `<top (required)>'
from /usr/lib/ruby/2.1.0/psych.rb:7:in `require'

according to that that is a bundler issue, and you have to add

gem 'psych'

to your Gemfile.local

参照