Redmineを入れた話

1人プロジェクトのため、Redmineを入れてみた。
チケット駆動でやるっていうのをやりたかったし、Linux管理の勉強にもなるかと思って。
インストール手順は下記記事のお世話になりました。
Redmine 1.1をCentOS5.5にインストールする手順 | Redmine.JP Blog

入れる前の環境
最終的に目指す環境

サブディレクトリでRedmineを実行するようにApacheは設定する。

必要なパッケージのインストール

開発ツール(Cコンパイラ等):

# yum groupinstall "Development Tools"

or

# yum -y install gcc

Toolsだと、subversionとかもバージョン上がってしまう。
gccだけいれたほうがいい。

メモ

[開発ツール群を削除]

# yum groupremove "Development Tools"

インストールつづき

RubyとPassengerのビルドに必要なヘッダファイルなど:

# yum install openssl-devel readline-devel zlib-devel curl-devel

MySQLとヘッダファイル:

# yum install mysql-server mysql-devel

Apacheのヘッダファイル
httpdは入っているのでいれなかった。

# yum install httpd-devel

Complete!って出るまで延々インストール

Rubyのインストール

ダウンロード
Download — Ruby Enterprise Edition

/usr/local/src に コピー

# cd /usr/local/src

解凍

# tar xzvf ruby-enterprise-1.8.7-2011.03.tar.gz

インストーラの実行

# ./ruby-enterprise-1.8.7-2011.03/installer --dont-install-useful-gems --no-dev-docs
	Welcome to the Ruby Enterprise Edition installer
	This installer will help you install Ruby Enterprise Edition 1.8.7-2011.03.
	Don't worry, none of your system files will be touched if you don't want them
	to, so there is no risk that things will screw up.

	You can expect this from the installation process:

	  1. Ruby Enterprise Edition will be compiled and optimized for speed for this
	     system.
	  2. Ruby on Rails will be installed for Ruby Enterprise Edition.
	  3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
	     Edition instead of regular Ruby.

	Press Enter to continue, or Ctrl-C to abort.

	Checking for required software...

	 * C compiler... found at /usr/bin/gcc
	 * C++ compiler... found at /usr/bin/g++
	 * The 'make' tool... found at /usr/bin/make
	 * The 'patch' tool... found at /usr/bin/patch
	 * Zlib development headers... found
	 * OpenSSL development headers... found
	 * GNU Readline development headers... found
	--------------------------------------------
	Target directory

	Where would you like to install Ruby Enterprise Edition to?
	(All Ruby Enterprise Edition files will be put inside that directory.)
	インストール先(Target Directory)の入力
	[/opt/ruby-enterprise-1.8.7-2011.03] : /usr/local/
	・・・・
	Enjoy Ruby Enterprise Edition, a product of Phusion (www.phusion.nl) :-)

RubyGems1.4.2のインストール

Ruby Enterprise Editionと共にインストールされるRubyGems1.5.2ではRedmineが実行できないので
RubyGemsを1.4.2にダウングレードします。

# gem update --system 1.4.2
	Updating rubygems-update
	Fetching: rubygems-update-1.4.2.gem (100%)
	Successfully installed rubygems-update-1.4.2
	Installing RubyGems 1.4.2
	RubyGems 1.4.2 installed
	File not found: README
# gem --version

1.4.2 とでればおっけー。

Rack 1.0.1のインストール

# gem install rack -v=1.0.1

i18n 0.4.2のインストール

# gem install i18n -v=0.4.2

RubyMySQLドライバーのインストール

# gem install mysql

No definition for next_result と延々でるが気にしなくてよいらしい。

MySQLの設定

configファイルをコピーする

cp -p /usr/share/mysql/my-small.cnf /etc/my.cnf

configファイルの編集

# vi /etc/my.cnf
	# The MySQL server
	[mysqld]
	port            = 3306
	socket          = /var/lib/mysql/mysql.sock
	skip-locking
	key_buffer = 16K
	max_allowed_packet = 1M
	table_cache = 4
	sort_buffer_size = 64K
	read_buffer_size = 256K
	read_rnd_buffer_size = 256K
	net_buffer_length = 2K
	thread_stack = 128K
	# adding 2011-04-12
	default-character-set=utf8

	# Don't listen on a TCP/IP port at all. This can be a security enhancement,
	# if all processes that need to connect to mysqld run on the same host.
	# All interaction with mysqld must be made via Unix sockets or named pipes.
	# Note that using this option without enabling named pipes on Windows
	# (using the "enable-named-pipe" option) will render mysqld useless!
	#
	#skip-networking
	server-id       = 1

	# Uncomment the following if you want to log updates
	#log-bin=mysql-bin

	# Disable Federated by default
	skip-federated

	# Uncomment the following if you are NOT using BDB tables
	#skip-bdb

	# Uncomment the following if you are using InnoDB tables
	#innodb_data_home_dir = /var/lib/mysql/
	#innodb_data_file_path = ibdata1:10M:autoextend
	#innodb_log_group_home_dir = /var/lib/mysql/
	#innodb_log_arch_dir = /var/lib/mysql/
	# You can set .._buffer_pool_size up to 50 - 80 %
	# of RAM but beware of setting memory usage too high
	#innodb_buffer_pool_size = 16M
	#innodb_additional_mem_pool_size = 2M
	# Set .._log_file_size to 25 % of buffer pool size
	#innodb_log_file_size = 5M
	#innodb_log_buffer_size = 8M
	#innodb_flush_log_at_trx_commit = 1
	#innodb_lock_wait_timeout = 50

	[mysqldump]
	quick
	max_allowed_packet = 16M

	[mysql]
	no-auto-rehash
	# Remove the next comment character if you are not familiar with SQL
	#safe-updates
	# adding 2011-04-12
	default-character-set=utf8

	[isamchk]
	key_buffer = 8M
	sort_buffer_size = 8M

	[myisamchk]
	key_buffer = 8M
	sort_buffer_size = 8M

MySQLの起動および自動起動の設定

# /etc/init.d/mysqld start
# chkconfig mysqld on

/etc/my.cnf への設定が反映されていることの確認(UTF-8になっていること)

# mysql -uroot
mysql> show variables like 'character_set%';	
	+--------------------------+----------------------------+
	| Variable_name            | Value                      |
	+--------------------------+----------------------------+
	| character_set_client     | utf8                       |
	| character_set_connection | utf8                       |
	| character_set_database   | utf8                       |
	| character_set_filesystem | binary                     |
	| character_set_results    | utf8                       |
	| character_set_server     | utf8                       |
	| character_set_system     | utf8                       |
	| character_sets_dir       | /usr/share/mysql/charsets/ |
	+--------------------------+----------------------------+
	8 rows in set (0.00 sec)

rootユーザーのパスワード変更・匿名ユーザー削除

# mysql -uroot	
mysql> use mysql;	
mysql> update user set password=password('パスワード') where user = 'root';	
mysql> delete from user where user = '';	
mysql> flush privileges;	
mysql> exit;	

Redmine用データベースとユーザーの作成

# mysql -uroot -p	
mysql> create database db_redmine default character set utf8;	
mysql> grant all on db_redmine.* to user_redmine identified by 'パスワード';	
mysql> flush privileges;	
mysql> exit;	

Redmineのインストール

redmine 1.1.2 ダウンロード
http://rubyforge.org/frs/?group_id=1850

/usr/local/src に転送

解凍

# tar zxvf redmine-1.1.2.tar.gz

Redmineの配置先のディレクトリを決定し、そこへ展開したファイルを移動します。
例えば、/var/lib/redmine を配置先とする場合、以下のようにします。

# mv redmine-1.1.2 /var/lib/redmine

database.ymlの設定

# cd /var/lib/redmine/config
# cp -p database.yml.example database.yml
# vi database.yml
	# MySQL (default setup).

	production:
	  adapter: mysql
	  database: db_redmine
	  host: localhost
	  username: user_redmine
	  password: パスワード
	  encoding: utf8

email.ymlの設定

今回メール使っていないが、枠だけ作成

# cp -p email.yml.example email.yml
# vi email.yml
	production:
	  delivery_method: :smtp
	  smtp_settings:
	    address: localhost
	    port: 25
	    domain: serverdomain
	    #authentication: :login
	    #user_name: "redmine@example.net"
	    #password: "パスワード"

Redmineの初期設定とデータベースのテーブル作成

セッションデータ暗号化用鍵の生成とテーブル作成

# cd /var/lib/redmine
# rake generate_session_store
# rake db:migrate RAILS_ENV=production

※もし、rakeコマンドがないといわれたら

# gem install rake --remote

Passengerのインストール

# gem install passenger

PassengerのApache用モジュールのインストール

# passenger-install-apache2-module --snippet
# vi /etc/httpd/conf.d/passenger.conf
	# Passengerの基本設定。
	# passenger-install-apache2-module --snippet を実行して表示される設定を使用。
	# 環境によって設定値が異なりますので以下の3行はそのまま転記しないでください。
	#
	LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.6/ext/apache2/mod_passenger.so
	PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.6
	PassengerRuby /usr/local/bin/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のチューニングのための設定を追加。
	#
	PassengerMaxPoolSize 20
	PassengerMaxInstancesPerApp 4
	PassengerPoolIdleTime 3600
	PassengerUseGlobalQueue on
	PassengerHighPerformance on
	PassengerStatThrottleRate 10
	RailsSpawnMethod smart
	RailsAppSpawnerIdleTime 86400
	RailsFrameworkSpawnerIdleTime 0

	RailsBaseURI /redmine

worker MPMに切り替えるをやっていない。必要であればやる。

# /etc/init.d/httpd restart

Apache上のPassengerでRedmineを実行するための設定

# chown -R apache:apache /var/lib/redmine
# ln -s /var/lib/redmine/public /var/www/html/redmine
# /etc/init.d/httpd configtest

Syntax OK

# /etc/init.d/httpd graceful

起動確認

http://domain/redmine

画面が表示されればオッケー!

あとは、

  • ユーザー作成
  • プロジェクト作成
  • カテゴリ作成
  • チケット作成
  • subversion連携