Redmine+MySQLをCent君で動かすまでのメモ

忘れないうちに、一連の手順をメモっておこう

以下を確認する
# rpm -qa | grep mysql
mysql-devel-5.0.45-7.el5
mysql-server-5.0.45-7.el5
mysql-5.0.45-7.el5

/etc/my.cnf の編集
[mysqld] セクションに以下を追加
default-character-set=utf8

# service mysqld start

# rpm -qa | grep ruby
ruby-devel-1.8.5-5.el5_2.6
ruby-rdoc-1.8.5-5.el5_2.6
ruby-libs-1.8.5-5.el5_2.6
ruby-1.8.5-5.el5_2.6
ruby-irb-1.8.5-5.el5_2.6
ruby-mode-1.8.5-5.el5_2.6
ruby-ri-1.8.5-5.el5_2.6

rpmfindからDLした rubygems-1.3.1-1.el5.src.rpm

# pmbuild --rebuild rubygems-1.3.1-1.el5.src.rpm
# cd /usr/src/redhat/RPMS/noarch
# rpm -Uhv rubygems-1.3.1-1.noarch.rpm

# gem install mysql -- --with-mysql-lib=/usr/lib/mysql
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed

# gem install rails
Successfully installed rake-0.8.3
Successfully installed activesupport-2.2.2
Successfully installed activerecord-2.2.2
Successfully installed actionpack-2.2.2
Successfully installed actionmailer-2.2.2
Successfully installed activeresource-2.2.2
Successfully installed rails-2.2.2
7 gems installed
以下略

# gem install passenger
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed fastthread-1.0.1
Successfully installed rack-0.9.1
Successfully installed passenger-2.0.6
3 gems installed
以下略

# passenger-install-apache2-module
かなり長いけど略

/etc/httpd/conf/httpd.conf に以下を追加

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby

# IPベースのバーチャルホストで動かす場合の設定
NameVirtualHost add-addr

Options FollowSymLinks
DocumentRoot /path/to/redmine/public
ServerName redmine

# cd /etc/sysconfig/network-scripts
# cp ifcfg-eth0 ifcfg-eth0:0
DEVICE=eth0:0 # :0を追加
IPADDR=add-addr # アドレスを変更

/etc/hosts に以下を追加
add-addr redmine

# service network restart
# service httpd restart

/path/to/redmine/config/ 以下で
# cp database.yml.example database.yml
# vi database.yml
production:
database: redmine # に修正

# vi environment.rb
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

# mysql -u root
mysql> create database redmine;
mysql> show databases; # redmine が出来たか確認
mysql> use redmine
mysql> show tables from redmine; # これは単なるメモ
mysql> exit

/path/to/redmine 以下で
# rake db:migrate RAILS_ENV=production
# rake load_default_data RAILS_ENV=production

でブラウザから http://add-addr/ でアクセス出来れば成功