Redmine1.2 on ScientificLinux 6.1

準備

設定シート

項目

設定値(参考)

備考

Ruby Enterprise Editionインストールディレクトリ

/usr/local/

MySQL管理者パスワード

password

推測されにくい物

Redmine用データベース名

db_redmine

推測されにくい名前をつけてください。

Redmine用データベース管理者名

user_redmine

Redmine用データベース管理者パスワード

password

このパスワードは、設定ファイルに書き込みます。

初期管理者名

admin

初期管理者パスワード

admin

開発環境・必須パッケージのインストール

以下の物を導入します。

  1. 開発環境と各種ヘッダーファイル
  2. mysql
  3. apache

開発環境・各種ヘッダーファイルなど

[root@sl6 ~]# yum -y groupinstall "Development Tools"

[root@sl6 ~]# yum -y install openssl-devel readline-devel zlib-devel curl-devel

mysql

[root@sl6 ~]# yum -y install mysql-server mysql-devel

apache

[root@sl6 ~]# yum -y install httpd httpd-devel

Rubyのインストール

Ruby Enterprise Edition とやらを使うと良いらしいので、言われたとおりにしてみます。

ソースファイルのダウンロード

[root@sl6 ~]# wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz

インストール

[root@sl6 ~]# tar zxf ruby-enterprise-1.8.7-2011.03.tar.gz

[root@sl6 ~]# ./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.)

[/opt/ruby-enterprise-1.8.7-2011.03] : /usr/local/

--------------------------------------------

Compiling and optimizing the memory allocator for Ruby Enterprise Edition

In the mean time, feel free to grab a cup of coffee.

./configure --prefix=/usr/local --disable-dependency-tracking

checking build system type... i686-pc-linux-gnu

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

------------------------------------------------------------------------------

RubyGems installed the following executables:

            /usr/local/bin/gem

/usr/local/bin/ruby extconf.rb

checking for iconv() in iconv.h... yes

checking for const of iconv() 2nd argument... no

creating Makefile

make clean

make

gcc  -I. -I/opt/local/include -I. -I/usr/local/lib/ruby/1.8/i686-linux -I. -DHAVE_ICONV  -D_FILE_OFFSET_BITS=64  -fPIC -g -O2        -c iconv.c

gcc -shared -o iconv.so iconv.o -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L.  -rdynamic -Wl,-export-dynamic        -L/opt/local/lib -lrt -ldl -lcrypt -lm   -lc

make install

/usr/bin/install -c -m 0755 iconv.so /usr/local/lib/ruby/site_ruby/1.8/i686-linux

--------------------------------------------

Installing useful libraries...

/usr/local/bin/ruby /usr/local/bin/gem sources --update

source cache successfully updated

Updating /usr/local/bin/irb...

Updating /usr/local/bin/erb...

Updating /usr/local/bin/testrb...

Updating /usr/local/bin/ri...

Updating /usr/local/bin/rdoc...

Updating /usr/local/bin/gem...

--------------------------------------------

Ruby Enterprise Edition is successfully installed!

If want to use Phusion Passenger (http://www.modrails.com) in combination

with Ruby Enterprise Edition, then you must reinstall Phusion Passenger against

Ruby Enterprise Edition, as follows:

  /usr/local/bin/passenger-install-apache2-module

Make sure you don't forget to paste the Apache configuration directives that

the installer gives you.

If you ever want to uninstall Ruby Enterprise Edition, simply remove this

directory:

  /usr/local

If you have any questions, feel free to visit our website:

  http://www.rubyenterpriseedition.com

Enjoy Ruby Enterprise Edition, a product of Phusion (www.phusion.nl) :-)

[root@sl6 ~]#

Rubyパッケージ(gemパッケージ)のインストール

Rack1.1.1

サーバとWebアプリ用フレームワーク間のインターフェース(ライブラリ群)

rake0.8.7

ビルドツール

i18n 0.4.2

国際化対応

MySQLドライバ

MySQLドライバ

それぞれ、バージョンを指定している物は、その通りのバージョンでインストールしてください。

バージョン間の互換性に問題がるっぽいです。

[root@sl6 ~]# gem install rack -v=1.1.1 --no-rdoc --no-ri

[root@sl6 ~]# gem install rake -v=0.8.7 --no-rdoc --no-ri

[root@sl6 ~]# gem install i18n -v=0.4.2 --no-rdoc --no-ri

[root@sl6 ~]# gem install mysql --no-rdoc --no-ri

MySQLの設定

  1. 標準のキャラクタセットをUTF8に設定
  2. 管理者(root)パスワードの設定、テストデータベース削除
  3. Redmine用データベース作成

標準キャラクタセットの設定

ついでに、中規模向けMySQL設定ファイルを適用しておきます。

[root@sl6 ~]# cp /etc/my.cnf /etc/my.cnf.org

[root@sl6 ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

cp: overwrite `/etc/my.cnf'? y

[root@sl6 ~]# vi /etc/my.cnf

# Example MySQL config file for medium systems.

#

# This is for a system with little memory (32M - 64M) where MySQL plays

# an important part, or systems up to 128M where MySQL is used together with

# other programs (such as a web server)

#

# You can copy this file to

# /etc/my.cnf to set global options,

# mysql-data-dir/my.cnf to set server-specific options (in this

# installation this directory is /var/lib/mysql) or

# ~/.my.cnf to set user-specific options.

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

[client]

#password           = your_password

port                = 3306

socket              = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

port                = 3306

socket              = /var/lib/mysql/mysql.sock

skip-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

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

# (via the "enable-named-pipe" option) will render mysqld useless!

#

#skip-networking

# Replication Master Server (default)

# binary logging is required for replication

log-bin=mysql-bin

# binary logging format - mixed recommended

binlog_format=mixed

# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master if omitted

server-id           = 1

# Replication Slave (comment out master section to use this)

#

# To configure this host as a replication slave, you can choose between

# two methods :

#

# 1) Use the CHANGE MASTER TO command (fully described in our manual) -

#        the syntax is:

#

#        CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,

#        MASTER_USER=<user>, MASTER_PASSWORD=<password> ;

#

#        where you replace <host>, <user>, <password> by quoted strings and

#        <port> by the master's port number (3306 by default).

#

#        Example:

#

#        CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,

#        MASTER_USER='joe', MASTER_PASSWORD='secret';

#

# OR

#

# 2) Set the variables below. However, in case you choose this method, then

#        start replication for the first time (even unsuccessfully, for example

#        if you mistyped the password in master-password and the slave fails to

#        connect), the slave will create a master.info file, and any later

#        change in this file to the variables' values below will be ignored and

#        overridden by the content of the master.info file, unless you shutdown

#        the slave server, delete master.info and restart the slaver server.

#        For that reason, you may want to leave the lines below untouched

#        (commented) and instead use CHANGE MASTER TO (see above)

#

# required unique id between 2 and 2^32 - 1

# (and different from the master)

# defaults to 2 if master-host is set

# but will not function as a slave if omitted

#server-id           = 2

#

# The replication master for this slave - required

#master-host         =   <hostname>

#

# The username the slave will use for authentication when connecting

# to the master - required

#master-user         =   <username>

#

# The password the slave will authenticate with when connecting to

# the master - required

#master-password =   <password>

#

# The port the master is listening on.

# optional - defaults to 3306

#master-port         =  <port>

#

# binary logging - not required for slaves, but recommended

#log-bin=mysql-bin

# Point the following paths to different dedicated disks

#tmpdir             = /tmp/

#log-update         = /path-to-dedicated-directory/hostname

# 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/

# 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

default-character-set=utf8

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

default-character-set=utf8

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

default-character-set=utf8

[mysqlhotcopy]

interactive-timeout

default-character-set=utf8

[root@sl6 ~]#

管理者パスワードの設定・テストデータベース削除

[root@sl6 ~]# service mysqld start

Initializing MySQL database:  Installing MySQL system tables...

111024 14:42:33 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

111024 14:42:33 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.

OK

Filling help tables...

111024 14:42:33 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

111024 14:42:33 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.

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 sl6.example.co.jp 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 /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                               [  OK  ]

Starting mysqld:                                               [  OK  ]

[root@sl6 ~]# chkconfig mysqld on

[root@sl6 ~]# mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.1.52-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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)

mysql> quit

[root@sl6 ~]# mysqladmin -u root password "password"

[root@sl6 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.1.52-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

mysql> select user() from mysql.user;

+----------------+

| user()             |

+----------------+

| root@localhost |

| root@localhost |

| root@localhost |

| root@localhost |

| root@localhost |

+----------------+

5 rows in set (0.00 sec)

mysql>

mysql> show databases;

+--------------------+

| Database               |

+--------------------+

| information_schema |

| mysql                  |

| test                   |

+--------------------+

3 rows in set (0.00 sec)

mysql> drop database test;

Query OK, 0 rows affected (0.00 sec)

mysql>

Redmine用データベース作成

mysql> create database db_redmine;

Query OK, 1 row affected (0.00 sec)

mysql> grant all on db_redmine.* to user_redmine@localhost identified by 'password';

Query OK, 0 rows affected (0.00 sec)

mysql> show grants for user_redmine@localhost;

+---------------------------------------------------------------------------------------------------------------------+

| Grants for user_redmine@localhost                                                                                       |

+---------------------------------------------------------------------------------------------------------------------+

| GRANT USAGE ON *.* TO 'user_redmine'@'localhost' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |

| GRANT ALL PRIVILEGES ON `db_redmine`.* TO 'user_redmine'@'localhost'                                                    |

+---------------------------------------------------------------------------------------------------------------------+

2 rows in set (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

[root@sl6 ~]#

Redmineのインストール

  1. ソースファイル?のダウンロード、展開、配置
  2. 設定

ソースファイルのダウンロード、展開、配置

[root@sl6 ~]# wget http://rubyforge.org/frs/download.php/75518/redmine-1.2.2.tar.gz

[root@sl6 ~]# tar zxf redmine-1.2.2.tar.gz

[root@sl6 ~]# chown -R apache:apache redmine-1.2.2

[root@sl6 ~]# mv redmine-1.2.2 /var/www/redmine

設定

・database

[root@sl6 ~]# cd /var/www/redmine/

[root@sl6 redmine]# cp config/database.yml.example config/database.yml

[root@sl6 redmine]# vi config/database.yml

production:

  adapter: mysql

  database: db_redmine

  host: localhost

  username: user_redmine

  password: password

  encoding: utf8

[root@sl6 redmine]#


・メール送信設定

[root@sl6 redmine]# cp config/configuration.yml.example config/configuration.yml

[root@sl6 redmine]# vi config/configuration.yml

# specific configuration options for production environment

# that overrides the default ones

production:

 email_delivery:

   delivery_method: :smtp

   smtp_settings:

     address: "localhost"

     port: 25

      domain: 'redmine.example.co.jp'

[root@sl6 redmine]#

セッションストア シークレットの作成および初期設定

[root@sl6 redmine]# rake generate_session_store

(in /var/www/redmine)

[root@sl6 redmine]# rake db:migrate RAILS_ENV=production  

Passengerモジュールの導入

インストール

[root@sl6 redmine]# gem install passenger --no-rdoc --no-ri

Fetching: fastthread-1.0.7.gem (100%)

Building native extensions.  This could take a while...

Fetching: daemon_controller-0.2.6.gem (100%)

Fetching: passenger-3.0.9.gem (100%)

Successfully installed fastthread-1.0.7

Successfully installed daemon_controller-0.2.6

Successfully installed passenger-3.0.9

3 gems installed

[root@sl6 redmine]# passenger-install-apache2-module

Welcome to the Phusion Passenger Apache 2 module installer, v3.0.9.

This installer will guide you through the entire installation process. It

shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.

 2. You'll learn how to configure Apache.

 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to

solve any problems.

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

--------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--------------------------------------------

The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so

   PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.11

   PassengerRuby /usr/local/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails

applications on Apache, without any further Ruby on Rails-specific

configuration!

Press ENTER to continue.

--------------------------------------------

Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your

Apache configuration file and set its DocumentRoot to /somewhere/public:

   <VirtualHost *:80>

          ServerName www.yourhost.com

          DocumentRoot /somewhere/public        # <-- be sure to point to 'public'!

          <Directory /somewhere/public>

             AllowOverride all                  # <-- relax Apache security settings

             Options -MultiViews                # <-- MultiViews must be turned off

          </Directory>

   </VirtualHost>

And that's it! You may also want to check the Users Guide for security and

optimization tips, troubleshooting and other useful information:

  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.11/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)

http://www.modrails.com/

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

[root@sl6 redmine]#

アクセス権の調整

[root@sl6 redmine]# chown apache:apache public/plugin_assets/

Apacheの設定

Passenger モジュールの設定

[root@sl6 redmine]# vi /etc/httpd/conf.d/redmine.conf

## 以下の設定は、環境によって異なります。

## passenger インストール時の表示から引用してください

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9/ext/apache2/mod_passenger.so

PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.9

PassengerRuby /usr/local/bin/ruby

Header always unset "X-Powered-By"

Header always unset "X-Rack-Cache"

Header always unset "X-Content-Digest"

Header always unset "X-Runtime"

PassengerMaxPoolSize 20

PassengerMaxInstancesPerApp 4

PassengerPoolIdleTime 3600

PassengerUseGlobalQueue on

PassengerHighPerformance on

PassengerStatThrottleRate 10

RailsSpawnMethod smart

RailsAppSpawnerIdleTime 86400

RailsFrameworkSpawnerIdleTime 0

[root@sl6 redmine]#

Apache本体の設定

DocumentRootを標準の値から変更する時は、SeLinuxを無効にする必要があります。

※SeLinuxへの設定追加・変更でも対応できますが、それは別の機会にでも。。。また、iptablesが有効になっている時は、80/tcp へのアクセスを許可するように設定してください。

[root@sl6 redmine]# vi /etc/httpd/conf/httpd.conf

##DocumentRoot "/var/www/html"

DocumentRoot "/var/www/redmine/public"

# This should be changed to whatever you set DocumentRoot to.

#

##<Directory "/var/www/html">

<Directory "/var/www/redmine/public">

[root@sl6 redmine]#  service httpd start

[root@sl6 ~]# chkconfig httpd on


Redmineへのアクセス

Webサーバが起動したら、ブラウザでアクセスします。

最初の画面

右上の”login"ボタンを押してログイン画面に移動します

初期管理アカウントを使ってログインします

初期管理者名                :admin

初期管理者パスワード        :admin

あとは適当に使います

Comments