CentOS5.8上でRedmineの構築を行う。
・Rubyのインストール
[root@goodjob goodjob]# yum groupinstall "Development Tools"
<省略>
Transaction Summary
================================================================================
Install 0 Package(s)
Upgrade 9 Package(s)
Total download size: 8.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): rpm-python-4.4.2.3-28.el5_8.i386.rpm | 61 kB 00:00
(2/9): popt-1.10.2.3-28.el5_8.i386.rpm | 76 kB 00:00
(3/9): strace-4.5.18-11.el5_8.i386.rpm | 172 kB 00:00
(4/9): systemtap-runtime-1.6-7.el5_8.i386.rpm | 211 kB 00:00
(5/9): rpm-build-4.4.2.3-28.el5_8.i386.rpm | 303 kB 00:00
(6/9): rpm-libs-4.4.2.3-28.el5_8.i386.rpm | 929 kB 00:01
(7/9): rpm-4.4.2.3-28.el5_8.i386.rpm | 1.2 MB 00:01
(8/9): gdb-7.0.1-42.el5.centos.i386.rpm | 2.4 MB 00:02
(9/9): systemtap-1.6-7.el5_8.i386.rpm | 2.8 MB 00:03
--------------------------------------------------------------------------------
Total 851 kB/s | 8.1 MB 00:09
警告: rpmts_HdrFromFdno: ヘッダ V3 DSA signature: NOKEY, key ID e8562897
updates/gpgkey | 1.5 kB 00:00
Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) <
centos-5-key@centos.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Is this ok [y/N]: y
<省略>
Complete!
[root@goodjob goodjob]# yum install zlib-devel openssl-devel
<省略>
Transaction Summary
================================================================================
Install 0 Package(s)
Upgrade 2 Package(s)
Total download size: 3.3 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): openssl-0.9.8e-22.el5_8.3.i686.rpm | 1.5 MB 00:01
(2/2): openssl-devel-0.9.8e-22.el5_8.3.i386.rpm | 1.9 MB 00:02
--------------------------------------------------------------------------------
Total 831 kB/s | 3.3 MB 00:04
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : openssl 1/4
Updating : openssl-devel 2/4
Cleanup : openssl 3/4
Cleanup : openssl-devel 4/4
Updated:
openssl-devel.i386 0:0.9.8e-22.el5_8.3
Dependency Updated:
openssl.i686 0:0.9.8e-22.el5_8.3
Complete!
[root@goodjob rubygems-1.8.11]# yum install ncurses-devel gdbm-devel openssl-devel zlib-devel readline-devel libyaml-devel
http://www.ruby-lang.org/ja/downloads/からruby-1.9.3-p125.tar.gzをダウンロード
[root@goodjob goodjob]# cp /mnt/hgfs/Desktop/openam/ruby-1.9.3-p125.tar.gz /usr/local/src
[root@goodjob src]# cd ruby-1.9.3-p125
[root@goodjob ruby-1.9.3-p125]# ./configure
[root@goodjob ruby-1.9.3-p125]# make
[root@goodjob ruby-1.9.3-p125]# make install
[root@goodjob ruby-1.9.3-p125]# ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]
・RubyGemsのインストール
http://rubyforge.org/frs/?group_id=126からrubygems-1.8.11.tarをダウンロード
[root@goodjob src]# cp /mnt/hgfs/Desktop/openam/rubygems-1.8.11.tar /usr/local/src
[root@goodjob src]# cd /usr/local/src
[root@goodjob src]# tar xvf rubygems-1.8.11.tar
[root@goodjob src]# cd xvf rubygems-1.8.11
[root@goodjob rubygems-1.8.11]# ruby setup.rb
RubyGems 1.8.11 installed
== 1.8.11 / 2011-10-03
* Bug fix:
* Deprecate was moved to Gem::Deprecate to stop polluting the top-level
namespace.
------------------------------------------------------------------------------
RubyGems installed the following executables:
/usr/local/bin/gem
[root@goodjob rubygems-1.8.11]# gem --version
1.8.11
・Ruby on Ralisのインストール
http://www.redmine.org/projects/redmine/wiki/RedmineInstall
より、Rails 2.3.14をインストールする。
[root@goodjob rubygems-1.8.11]# gem install rails -v 2.3.14
・EPELを使用するための設定
[root@goodjob rubygems-1.8.11]# rpm -Uvh
http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/5/i386/epel-release-5-4.noarch.rpm
http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/5/i386/epel-release-5-4.noarch.rpm を取得中
警告: /var/tmp/rpm-xfer.F3SnXg: ヘッダ V3 DSA signature: NOKEY, key ID 217521f6
準備中... ########################################### [100%]
1:epel-release ########################################### [100%]
[root@goodjob rubygems-1.8.11]# yum repolist
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base:
ftp.tsukuba.wide.ad.jp
* epel:
ftp.kddilabs.jp
* extras:
ftp.tsukuba.wide.ad.jp
* updates:
ftp.jaist.ac.jp
epel | 3.7 kB 00:00
epel/primary_db | 3.2 MB 00:03
repo id repo name status
base CentOS-5 - Base 2,725
epel Extra Packages for Enterprise Linux 5 - i386 5,486
extras CentOS-5 - Extras 276
updates CentOS-5 - Updates 272
repolist: 8,759
・MySQLのインストール
[root@goodjob rubygems-1.8.11]# yum install mysql mysql-server mysql-devel
<省略>
Transaction Summary
================================================================================
Install 5 Package(s)
Upgrade 0 Package(s)
Total download size: 18 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): perl-DBD-MySQL-3.0007-2.el5.i386.rpm | 148 kB 00:00
(2/5): perl-DBI-1.52-2.el5.i386.rpm | 600 kB 00:00
(3/5): mysql-devel-5.0.95-1.el5_7.1.i386.rpm | 2.4 MB 00:02
(4/5): mysql-5.0.95-1.el5_7.1.i386.rpm | 4.9 MB 00:05
(5/5): mysql-server-5.0.95-1.el5_7.1.i386.rpm | 9.8 MB 00:11
--------------------------------------------------------------------------------
Total 801 kB/s | 18 MB 00:22
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-DBI 1/5
Installing : mysql 2/5
Installing : perl-DBD-MySQL 3/5
Installing : mysql-devel 4/5
Installing : mysql-server 5/5
Installed:
mysql.i386 0:5.0.95-1.el5_7.1 mysql-devel.i386 0:5.0.95-1.el5_7.1
mysql-server.i386 0:5.0.95-1.el5_7.1
Dependency Installed:
perl-DBD-MySQL.i386 0:3.0007-2.el5 perl-DBI.i386 0:1.52-2.el5
Complete!
[root@goodjob rubygems-1.8.11]# vi /etc/my.cnf
※★の箇所を追加する。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set=utf8 ★追加
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default-character-set=utf8 ★追加
・MySQLの起動
[root@goodjob rubygems-1.8.11]# /etc/init.d/mysqld start
MySQL データベースを初期化中: WARNING: The host 'goodjob.openam.net' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h goodjob.openam.net password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at
http://shop.mysql.com
[ OK ]
MySQL を起動中: [ OK ]
・MySQLのパスワード変更、匿名ユーザの削除
[root@goodjob rubygems-1.8.11]# mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> update user set password=password('goodjob') where user = 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> delete from user where user = '';
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
・Redmine用ユーザの作成
[root@goodjob rubygems-1.8.11]# mysql -uroot -p
Enter password: goodjob
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.95 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database redmine default character set utf8;
Query OK, 1 row affected (0.02 sec)
mysql> grant all privileges on redmine.* to
'mysql'@'localhost' identified by 'goodjob';
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
・MySQLの自動起動設定
[root@goodjob rubygems-1.8.11]# /sbin/chkconfig mysqld on
[root@goodjob rubygems-1.8.11]# /sbin/chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
・MySQLのデータベースアクセスライブラリのインストール
[root@goodjob rubygems-1.8.11]# yum install mysql -- --with-mysql-lib=/usr/lib/mysql
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
・ImageMagickのインストール
[root@goodjob src]# wget
ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.7.6-8.tar.gz
[root@goodjob src]# gzip -dc ImageMagick-6.7.6-8.tar.gz | tar xvf -
[root@goodjob src]# cd ImageMagick-6.7.6-8
[root@goodjob ImageMagick-6.7.6-8]# ./configure
[root@goodjob ImageMagick-6.7.6-8]# make
[root@goodjob ImageMagick-6.7.6-8]# make install
・mstcorefontsのインストール
[root@goodjob rubygems-1.8.11]# yum install rpm-build ttmkfdir cabextract
<省略>
Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 93 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): cabextract-1.3-1.el5.i386.rpm | 39 kB 00:00
(2/2): libmspack-0.2-0.1.20100723alpha.el5.i386.rpm | 53 kB 00:00
--------------------------------------------------------------------------------
Total 142 kB/s | 93 kB 00:00
警告: rpmts_HdrFromFdno: ヘッダ V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey | 1.7 kB 00:00
Importing GPG key 0x217521F6 "Fedora EPEL <
epel@fedoraproject.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libmspack 1/2
Installing : cabextract 2/2
Installed:
cabextract.i386 0:1.3-1.el5
Dependency Installed:
libmspack.i386 0:0.2-0.1.20100723alpha.el5
Complete!
[root@goodjob msttcorefonts]# mkdir /usr/local/src/msttcorefonts
[root@goodjob msttcorefonts]# cd /usr/local/src/msttcorefonts/
[root@goodjob msttcorefonts]# wget
http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec
[root@goodjob msttcorefonts]# rpmbuild -bb msttcorefonts-2.0-1.spec
[root@goodjob msttcorefonts]# rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm
[root@goodjob TrueType]# mkdir -p /usr/share/fonts/default/TrueType
[root@goodjob TrueType]# cd /usr/share/fonts/default/TrueType
[root@goodjob TrueType]# find /usr/share/fonts/msttcorefonts/ -exec ln -s {} \;
・RMagickのインストール
[root@goodjob rubygems-1.8.11]# gem list rmagick --all --remote
[root@goodjob ImageMagick-6.7.6-8]# PATH=/usr/local/bin:$PATH
[root@goodjob ImageMagick-6.7.6-8]# export PATH
[root@goodjob ImageMagick-6.7.6-8]# PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
[root@goodjob ImageMagick-6.7.6-8]# export PKG_CONFIG_PATH
[root@goodjob TrueType]# gem install rmagick --version 2.13.1
[root@goodjob ImageMagick-6.7.6-8]# gem list rmagick
*** LOCAL GEMS ***
rmagick (2.13.1)
・Redmineのダウンロード
http://rubyforge.org/frs/?group_id=1850からredmine-1.4.1.tar.gzをダウンロード
[root@goodjob src]# wget
http://rubyforge.org/frs/download.php/76033/redmine-1.4.1.tar.gz
[root@goodjob src]# tar zxvf redmine-1.4.1.tar.gz
[root@goodjob src]# mv redmine-1.4.1 /var/lib/redmine
[root@goodjob src]# chown -R apache:apache /var/lib/redmine
・database.ymlの設定
[root@goodjob src]# cp /var/lib/redmine/config/database.yml.example /var/lib/redmine/config/database.yml
[root@goodjob src]# vi /var/lib/redmine/config/database.yml
<変更前>
production:
adapter: mysql
database: redmine
host: localhost
username: root
password:
encoding: utf8
<変更後>
production:
adapter: mysql2 ★Ruby1.9系を使う場合
database: redmine
host: localhost
username: mysql
password: goodjob
encoding: utf8
・セッション管理用秘密鍵の生成
[root@goodjob src]# cd /var/lib/redmine/
[root@goodjob redmine]# gem install bundler
[root@goodjob redmine]# bundle install --without development test postgresql sqlite
[root@goodjob redmine]# rake generate_session_store
[root@goodjob redmine]# ls config/initializers/session_store.rb
config/initializers/session_store.rb
・データベースの初期化
[root@goodjob redmine]# gem install mysql
[root@goodjob redmine]# cd /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1
[root@goodjob mysql-2.8.1]# ruby ext/mysql_api/extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... yes
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
ext/mysql_api/extconf.rb:67: Use RbConfig instead of obsolete and deprecated Config.
creating Makefile
[root@goodjob mysql-2.8.1]# make
compiling ext/mysql_api/mysql.c
linking shared-object mysql_api.so
[root@goodjob mysql-2.8.1]# make install
/usr/bin/install -c -m 0755 mysql_api.so /usr/local/lib/ruby/site_ruby/1.9.1/i686-linux
installing default mysql_api libraries
[root@goodjob redmine]# cd /var/lib/redmine
[root@goodjob redmine]# ln -s /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/lib/mysql.rb lib/mysql.rb
[root@goodjob redmine]# rake db:migrate RAILS_ENV=production
[root@goodjob redmine]# rake redmine:load_default_data RAILS_ENV=production
Select language: ar, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja
====================================
Default configuration data loaded.
・configuration.ymlの設定
[root@goodjob redmine]# cd /var/lib/redmine/config
[root@goodjob config]# cp configuration.yml.example configuration.yml
[root@goodjob config]# vi configuration.yml
★以下の箇所を環境に合わせて編集する。
default:
# Outgoing emails configuration (see examples above)
email_delivery:
delivery_method: :smtp
smtp_settings:
address: smtp.example.net
port: 25
domain: example.net
authentication: :login
user_name: "
redmine@example.net"
password: "redmine"
・Apacheのインストール
[root@goodjob src]# yum install httpd httpd-devel
<省略>
Transaction Summary
================================================================================
Install 7 Package(s)
Upgrade 1 Package(s)
Total download size: 8.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): apr-util-devel-1.2.7-11.el5_5.2.i386.rpm | 53 kB 00:00
(2/8): expat-devel-1.95.8-8.3.el5_5.3.i386.rpm | 132 kB 00:00
(3/8): httpd-devel-2.2.3-63.el5.centos.1.i386.rpm | 153 kB 00:00
(4/8): apr-devel-1.2.7-11.el5_6.5.i386.rpm | 233 kB 00:00
(5/8): httpd-2.2.3-63.el5.centos.1.i386.rpm | 1.2 MB 00:01
(6/8): cyrus-sasl-devel-2.1.22-5.el5_4.3.i386.rpm | 1.4 MB 00:01
(7/8): db4-devel-4.3.29-10.el5_5.2.i386.rpm | 1.9 MB 00:02
(8/8): openldap-devel-2.3.43-25.el5.i386.rpm | 2.9 MB 00:03
--------------------------------------------------------------------------------
Total 720 kB/s | 8.0 MB 00:11
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : httpd 1/9
Installing : cyrus-sasl-devel 2/9
Installing : apr-devel 3/9
Installing : openldap-devel 4/9
Installing : expat-devel 5/9
Installing : db4-devel 6/9
Installing : apr-util-devel 7/9
Installing : httpd-devel 8/9
Cleanup : httpd 9/9
Installed:
httpd-devel.i386 0:2.2.3-63.el5.centos.1
Dependency Installed:
apr-devel.i386 0:1.2.7-11.el5_6.5
apr-util-devel.i386 0:1.2.7-11.el5_5.2
cyrus-sasl-devel.i386 0:2.1.22-5.el5_4.3
db4-devel.i386 0:4.3.29-10.el5_5.2
expat-devel.i386 0:1.95.8-8.3.el5_5.3
openldap-devel.i386 0:2.3.43-25.el5
Updated:
httpd.i386 0:2.2.3-63.el5.centos.1
Complete!
[root@goodjob src]# /sbin/chkconfig httpd on
[root@goodjob src]# /sbin/chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
・Passengerのインストール
[root@goodjob src]# gem install passenger
[root@goodjob src]# yum install curl-devel
[root@goodjob src]# passenger-install-apache2-module
・Apache+Passenger上でRedmine動作設定
[root@goodjob src]# vi /etc/httpd/conf/httpd.conf
<追記>
<VirtualHost *:80>
ServerName goodjob.openam.net
DocumentRoot /var/www/html
RailsBaseURI /redmine
</VirtualHost>
[root@goodjob src]# vi /etc/httpd/conf.d/passenger.conf
# Passengerの基本設定。
# passenger-install-apache2-module --snippet を実行して表示される設定を使用。
# 環境によって設定値が異なりますので以下の3行はそのまま転記しないでください。
#
LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
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
<変更>
#ServerName
www.exapmple.com:80
ServerName goodjob.openam.net:80
[root@goodjob src]# ln -s /var/lib/redmine/public /var/www/html/redmine
・SELinuxを利用している場合の設定変更
[root@goodjob src]# passenger-config --root
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
[root@goodjob src]# chcon -R -h -t httpd_sys_content_t /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
[root@goodjob redmine]# vi /etc/selinux/config
SELINUX=enforcing
↓
SELINUX=disabled
・Redmineの起動
[root@goodjob src]# /etc/init.d/httpd start
・ファイアウォールの停止
[root@goodjob src]# /etc/rc.d/init.d/iptables stop
・OS起動時にファイアウォールが起動しないように設定
[root@goodjob src]# /sbin/chkconfig iptables off
http://goodjob.openam.net/redmineにアクセスし、以下が表示されることを確認する。
<参考>
http://www.os.cis.iwate-u.ac.jp/wikky/wikky.cgi?redmine::Chapter3_%E7%AE%A1%E7%90%86%E8%80%85%E7%B7%A8