2012年2月16日木曜日

CentOS6.2 Redmine1.3.1構築メモ(3)

CentOS6.2にRedmine1.3.1を構築する手順をまとめてみました。
 Step1. パッケージおよびインストーラの準備
 Step2. MySQLの準備
 Step3. Ruby Enterprise Edition インストール
 Step4. Redmine インストール
 Step5. ApacheにPassenger組込み

■構成情報
・OS:        CentOS6.2(64bit)
・MySQL:     5.1.52(OSバンドル)
・Ruby:      1.8.7(Ruby Enterprise Editionを利用)
 ・rack:    1.1.2
 ・rake:    0.9.2
 ・i18n:    0.4.2
・gem:       1.6.2
・Apache:    2.2.15(OSバンドル)
・Passenger: 3.0.11
・Redmine:   1.3.1


Step5. ApacheにPassenger組込み
■Passengerのインストール
[root@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-1.0.0.gem (100%)
Fetching: passenger-3.0.11.gem (100%)
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-1.0.0
Successfully installed passenger-3.0.11
3 gems installed
[root@redmine ~]#


■PassengerのApache用モジュールのインストール
[root@redmine ~]# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.11.

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.


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

Checking for required software...

 * GNU C++ compiler... found at /usr/bin/g++
 * Curl development headers with SSL support... found
 * OpenSSL development headers... found
 * Zlib development headers... found
 * Ruby development headers... found
 * OpenSSL support for Ruby... found
 * RubyGems... found
 * Rake... found at /usr/local/bin/rake
 * rack... found
 * Apache 2... found at /usr/sbin/httpd
 * Apache 2 development headers... found at /usr/sbin/apxs
 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config

--------------------------------------------
Compiling and installing Apache 2 module...
(中略)

--------------------------------------------
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:

   
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      
   

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@redmine ~]#


■Apacheの設定
⇒worker MPMに切り替える
[root@redmine ~]# vi /etc/sysconfig/httpd
[root@redmine ~]# grep httpd.worker /etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker
HTTPD=/usr/sbin/httpd.worker ←追記

⇒passnger.conf作成
[root@redmine ~]# vi /etc/httpd/conf.d/passnger.conf
[root@redmine ~]# cat /etc/httpd/conf.d/passnger.conf
# output of "passenger-install-apache2-module"
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

# rails settings
RailsBaseURI /redmine

# 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
[root@redmine ~]#

⇒Apache自動起動設定
[root@redmine ~]# chkconfig httpd on; chkconfig --list httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@redmine ~]#

⇒Redmineディレクトリの所有者変更
[root@redmine ~]# chown -R apache: /opt/redmine-1.3.1

⇒サブディレクトリでRedmineを実行(シンボリックリンク作成)
[root@redmine ~]# ln -s /opt/redmine-1.3.1/public /var/www/html/redmine

⇒/etc/hosts修正
[root@redmine ~]# vi /etc/hosts
[root@redmine ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.xxx.234   redmine.kuitan.net redmine
[root@redmine ~]#


⇒Apacheを起動
[root@redmine ~]# /etc/init.d/httpd configtest
Syntax OK
[root@redmine ~]# /etc/init.d/httpd graceful
httpd not running, trying to start
[root@redmine ~]# /etc/init.d/httpd status
httpd.worker (pid  16808) を実行中...
[root@redmine ~]#


⇒ブラウザからアクセス
http://192.168.xxx.234/redmine
ログイン:admin/admin

★終了ーーー


■作業完了後のディスク使用状況
[root@redmine ~]# df -m
Filesystem           1M-ブロック    使用   使用可 使用% マウント位置
/dev/mapper/vg_redmine-lv_root
                          4607      3666       708  84% /
tmpfs                      751         1       751   1% /dev/shm
/dev/sda1                  485        33       428   7% /boot
[root@redmine ~]#


■初期状態のDBおよび添付ファイルをバックアップ
[root@redmine ~]# mkdir redmine_bk
[root@redmine ~]# mysqldump -u root db_redmine > /root/redmine_bk/db_redmine_initial.dbf
[root@redmine ~]# cd /opt/redmine-1.3.1/files/
[root@redmine files]# tar -zcf /root/redmine_bk/files_initial.tar.gz *
→初期状態ではfilesディレクトリにはdelete.meファイルしかないので実質的には不要。

[root@redmine ~]# ll /root/redmine_bk/
合計 60
-rw-r--r-- 1 root root 55227  2月  8 18:47 2012 db_redmine_initial.dbf
-rw-r--r-- 1 root root   151  2月  8 18:48 2012 files_initial.tar.gz
[root@redmine ~]#

0 件のコメント:

コメントを投稿