ラベル PostgreSQL の投稿を表示しています。 すべての投稿を表示
ラベル PostgreSQL の投稿を表示しています。 すべての投稿を表示

2019年7月5日金曜日

PostgreSQL 既存VIEWの変更(列を追加)

既存VIEWに列を追加する場合

CREATE OR REPLACE VIEW xxxxx で更新するのではなく

DROP VIEW xxxxx してから CREATE VIEW xxxxx

別名を変える場合や並び変える時もDROPしてからとなる。

はぁ、ハマってしまった・・・

2016年9月5日月曜日

CentOS logrotateでエラー

先日CentOS6.8、Apache+PHP+PostgreSQLを構築した。OSはテキストモード、アプリはソースからインストール。

構築後の週明け月曜日にこんなメールが・・・

------------------------------------
表題:Anacron job 'cron.daily' on xxxxx.jp
------------------------------------

本文:
/etc/cron.daily/logrotate:

syslogd: no process killed
error: error running shared postrotate script for '/var/log/postgresql.log '

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

PostgreSQLのログは/var/log/でconfは以下の通り

#vi /etc/rsyslog.conf
#追記

# Save PostgreSQL to postgresql.log
local0.* /var/log/postgresql.log


ログファイルのローテーション設定は以下の通り

# vi /etc/logrotate.d/postgresql

/var/log/postgresql.log {
rotate 12
weekly
missingok
sharedscripts
postrotate
/usr/bin/killall -HUP syslogd
endscript
}


あ、CentOS6.8・・・syslogdじゃなくてrsyslogdだ!
※6.4よりrsyslogがデフォルト

/var/log/postgresql.log {
rotate 12
weekly
missingok
sharedscripts
postrotate
/usr/bin/killall -HUP rsyslogd
endscript
}

これで無事解決(^^)

2014年10月30日木曜日

Redmine 2.6.0へアップグレード

redmine 2.5.3を2.6.0へアップグレード(tarボール版)

不満のあったPDFエクスポートが改善されたようなので2.6へアップしてみました。
でも2.6.1がすぐリリースされそうな予感ですが・・・

手順は以前アップグレードした時と同じです。

OS:CentOS 6.4
DB:PostgreSQL9.2.3
redmine:/home/redmine/public_html/
※プラグインは一切に使用していない

ruby:1.9.3p392
gem:1.8.23

●現在のGemList

# gem list --local

*** LOCAL GEMS ***

actionmailer (3.2.19, 3.2.17, 3.2.13)
actionpack (3.2.19, 3.2.17, 3.2.13)
activemodel (3.2.19, 3.2.17, 3.2.13)
activerecord (3.2.19, 3.2.17, 3.2.13)
activeresource (3.2.19, 3.2.17, 3.2.13)
activesupport (3.2.19, 3.2.17, 3.2.13)
arel (3.0.3, 3.0.2)
awesome_nested_set (2.1.6)
bigdecimal (1.1.0)
builder (3.0.0)
bundler (1.3.4)
capybara (2.1.0)
childprocess (0.5.3)
coderay (1.1.0, 1.0.9)
daemon_controller (1.1.2)
erubis (2.7.0)
fastthread (1.0.7)
ffi (1.9.3)
hike (1.2.3, 1.2.2, 1.2.1)
i18n (0.6.11, 0.6.9, 0.6.1)
io-console (0.3)
journey (1.0.4)
jquery-rails (2.0.3)
json (1.8.1, 1.8.0, 1.7.7, 1.5.5)
mail (2.5.4, 2.5.3)
metaclass (0.0.4)
mime-types (1.25.1, 1.23, 1.21)
mini_portile (0.5.3)
minitest (2.5.1)
mocha (1.0.0)
multi_json (1.10.1, 1.10.0, 1.7.7, 1.7.3, 1.7.2)
net-ldap (0.3.1)
nokogiri (1.6.1)
passenger (3.0.19)
pg (0.17.1, 0.15.1, 0.15.0)
polyglot (0.3.5, 0.3.4, 0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack-openid (1.4.2, 1.3.1)
rack-ssl (1.3.4, 1.3.3)
rack-test (0.6.2)
rails (3.2.19, 3.2.17, 3.2.13)
railties (3.2.19, 3.2.17, 3.2.13)
rake (10.1.1, 10.1.0, 10.0.4, 0.9.2.2)
rdoc (3.12.2, 3.9.5)
redcarpet (2.3.0)
rmagick (2.13.3, 2.13.2)
ruby-openid (2.3.0, 2.1.8)
rubyzip (1.1.3)
selenium-webdriver (2.41.0)
shoulda (3.3.2)
shoulda-context (1.0.2)
shoulda-matchers (1.4.1)
sprockets (2.2.2)
thor (0.19.1, 0.18.1, 0.18.0)
tilt (1.4.1, 1.4.0, 1.3.6)
treetop (1.4.15, 1.4.14, 1.4.12)
tzinfo (0.3.42, 0.3.39, 0.3.37)
websocket (1.0.7)
xpath (2.0.0)
yard (0.8.7.4)


●DBバックアップ
dbname:redmine(-U でdbuser指定), dbuser:redmine, バックアップはredmineのソースディレクトリに保存(db_日付.dumpで作成)

# /usr/local/pgsql/bin/pg_dump -U redmine -Fc redmine > /home/redmine/public_html/db_`date +%Y%m%d`.dump

●redmineのバックアップと2.6.0用ディレクトリの作成
public_htmlをpublic_html_253でバックアップ

# mv /home/redmine/public_html /home/redmine/public_html_253
# mkdir /home/redmine/public_html
# chmod 775 /home/redmine/public_html

redmine2.6.0のダウンロード
ソース解凍後に2.6.0用ディレクトリにソースを移動

# cd /usr/local/src/
# wget http://www.redmine.org/releases/redmine-2.6.0.tar.gz
# tar zxvf redmine-2.6.0.tar.gz
# mv ./redmine-2.6.0/* /home/redmine/public_html/

●設定ファイル等のコピー
追加したfarend_fancyというテーマも移行します。

# cd /home/redmine/public_html_253/
# cp ./config/database.yml /home/redmine/public_html/config/
# cp ./config/additional_environment.rb /home/redmine/public_html/config/
# cp -rf ./files/* /home/redmine/public_html/files/
# cp -r ./public/themes/farend_fancy /home/redmine/public_html/public/themes/

私はプラグインを使用していないため移行作業はありませんが移行するならば
# cp -r ./plugins/* /home/redmine/public_html/plugins/

ただし新バージョンでは動作しないことも考えられるためスムーズに移行できるとは限らない。redmine2.6に対応したバージョンがリリースされているか事前にチェックした方が良さそうです。

今はプラグインはここかな?
# mkdir ./public/plugin_assets

# cp -r /home/redmine/public_html_252/public/plugin_assets /home/redmine/public_html/public/plugin_assets

依存Gem関連のインストール
redmineはGemの依存管理をBundlerが行っているためBundlerをインストールしておく

# gem install bundler

# cd /home/redmine/public_html
# bundle install --without development test mysql sqlite sqlserver
(ImageMagickがインストールされていない場合はオプションにrmagic付加すればよい)

Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Installing rake (10.3.2) 
Using i18n (0.6.11) 
Using multi_json (1.10.1) 
Using activesupport (3.2.19) 
Installing builder (3.0.4) 
Using activemodel (3.2.19) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.3) 
Using tilt (1.4.1) 
Using sprockets (2.2.2) 
Using actionpack (3.2.19) 
Using mime-types (1.25.1) 
Using polyglot (0.3.5) 
Using treetop (1.4.15) 
Using mail (2.5.4) 
Using actionmailer (3.2.19) 
Using arel (3.0.3) 
Using tzinfo (0.3.42) 
Using activerecord (3.2.19) 
Using activeresource (3.2.19) 
Using bundler (1.3.4) 
Using coderay (1.1.0) 
Using rack-ssl (1.3.4) 
Using json (1.8.1) 
Using rdoc (3.12.2) 
Using thor (0.19.1) 
Using railties (3.2.19) 
Installing jquery-rails (3.1.2) 
Using net-ldap (0.3.1) 
Using pg (0.17.1) 
Using ruby-openid (2.3.0) 
Using rack-openid (1.4.2) 
Using rails (3.2.19) 
Installing rbpdf (1.18.2) 
Using redcarpet (2.3.0) 
Installing request_store (1.0.5) 
Using rmagick (2.13.3) 


●仕上げ


# rake generate_secret_token

# rake db:migrate RAILS_ENV=production

==  AddPasswordChangedAtToUser: migrating =====================================
-- add_column(:users, :passwd_changed_on, :datetime)
   -> 0.0587s
==  AddPasswordChangedAtToUser: migrated (0.0588s) ============================

==  InsertBuiltinGroups: migrating ============================================
==  InsertBuiltinGroups: migrated (0.7091s) ===================================

# rake redmine:plugins:migrate RAILS_ENV=production
# rake tmp:cache:clear
# rake tmp:sessions:clear

# chown -R daemon:daemon /home/redmine/public_html
# /usr/local/apache/bin/apachectl restart

データベースに大きな変更は無いようですね。
usersにパスワード変更日のようなフィールドが追加されたぐらいですかね。


Redmineの管理>情報
Environment:
  Redmine version                2.6.0.stable
  Ruby version                   1.9.3-p392 (2013-02-22) [i686-linux]
  Rails version                  3.2.19
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.6.11
  Git                            1.7.1
  Filesystem                     
Redmine plugins:
  no plugin installed

チケットの一覧をPDFで出力すると列幅が小さく見ずらい状態でしたが幅が広がり見やすくなりましたね。







2013年3月27日水曜日

CentOS6にRedmine2.3&PostgreSQL9.2

Redmine+PosgtreSQL+Apache+Passenger
  • Redmine:2.3.0
  • OS:  CentOS-6.4(x86) Minimal構成
  • Web: Apache-2.2.24(ソースから) Passenger実行
  • DB:  PostgreSQL-9.2.3(ソースから)
  • Ruby: Ruby1.9.3-p392(ソースから)
  • Rails: 3.2.13(Ruby同梱)

OSのインストール

ここでは構築手順を割愛させて頂きますが以下で構築したものをベースにしております。
CentOS6をVMwareにテキストモードでインストールしたもので参考になるかと思います。
http://stdman.blogspot.jp/2011/12/centos6.html

構成内容(
・IPv6:OFF
・パッケージ群:Base,Development Tools
・有効サービス:crond,iptables,network,ntpd,postfix,rsyslog,sshd,cpuspeed,irqbalance
・FireWall:OFF
・SELinux:OFF

●必要パッケージやリポジトリをインストール

Rubyのビルドで必要なEPELリポジトリのインストール
http://ftp.riken.jp/Linux/fedora/epel/6/i386/repoview/epel-release.htmlからRPMのダウンロード先リンクを取得します。
 
# rpm -Uvh http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

Retrieving http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.ZZztWP: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

EPELレポジトリのGPGキーのインポート
# rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
 
EPELレポジトリのGPGキーの確認
# rpm -q 'gpg-pubkey-*' --qf '%{name} -> %{summary}\n'
gpg-pubkey -> gpg(CentOS-6 Key (CentOS 6 Official Signing Key) )
gpg-pubkey -> gpg(EPEL (6) )


開発パッケージをインストール
# yum groupinstall "Development Tools"

その他必要なパッケージをインストール(PostgreSQL用)
# yum install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel ImageMagick ImageMagick-devel ipa-pgothic-fonts
※libyamlとlibyaml-develがEPELレポジトリから取得されました

依存関係により以下のパッケージも一緒にインストールされました

GConf2.i686 0:2.28.0-6.el6
ORBit2.i686 0:2.14.17-3.2.el6_3
bzip2-devel.i686 0:1.0.5-7.el6_0
fontpackages-filesystem.noarch 0:1.41-1.1.el6
freetype-devel.i686 0:2.3.11-14.el6_3.1
ghostscript.i686 0:8.70-15.el6_4.1
ghostscript-devel.i686 0:8.70-15.el6_4.1
ghostscript-fonts.noarch 0:5.50-23.1.el6
jasper-devel.i686 0:1.900.1-15.el6_1.1
keyutils-libs-devel.i686 0:1.4-4.el6
krb5-devel.i686 0:1.10.3-10.el6_4.1
lcms-devel.i686 0:1.19-1.el6
lcms-libs.i686 0:1.19-1.el6
libICE-devel.i686 0:1.0.6-1.el6
libIDL.i686 0:0.8.13-2.1.el6
libSM-devel.i686 0:1.2.1-2.el6
libX11-devel.i686 0:1.5.0-4.el6
libXau-devel.i686 0:1.0.6-4.el6
libXext-devel.i686 0:1.3.1-2.el6
libXfont.i686 0:1.4.5-2.el6
libXt.i686 0:1.1.3-1.el6
libXt-devel.i686 0:1.1.3-1.el6
libcom_err-devel.i686 0:1.41.12-14.el6
libcroco.i686 0:0.6.2-5.el6
libfontenc.i686 0:1.0.5-2.el6
libgsf.i686 0:1.14.15-5.el6
libidn-devel.i686 0:1.18-2.el6
libjpeg-turbo-devel.i686 0:1.2.1-1.el6
librsvg2.i686 0:2.26.0-5.el6_1.1.0.1.centos
libselinux-devel.i686 0:2.0.94-5.3.el6
libsepol-devel.i686 0:2.0.41-4.el6
libtiff-devel.i686 0:3.9.4-9.el6_3
libtool-ltdl.i686 0:2.2.6-15.5.el6
libwmf-lite.i686 0:0.2.8.4-22.el6.centos
libxcb-devel.i686 0:1.8.1-1.el6
libyaml.i686 0:0.1.3-1.el6
ncurses-devel.i686 0:5.7-3.20090208.el6
sgml-common.noarch 0:0.6.3-32.el6
urw-fonts.noarch 0:2.4-10.el6
xorg-x11-font-utils.i686 1:7.2-11.el6
xorg-x11-proto-devel.noarch 0:7.6-25.el6


●Apacheのインストール

ソースからインストールしています。
詳しくはこちらのインストールを参考にして頂ければと思います。

/usr/local/apacheにインストール、UserDirを公開
 

●PostgreSQLのインストール

ソースからインストールしています。
詳しくはこちらのインストールを参考にして頂ければと思います。
/usr/local/pgsqlにインストール、dataはpgsqlの直下
またPL/pgsqlが必要ですが9.0以降はデフォルトでインストールされます。
  
--------------------------------------------------------
DB名:redmine、ユーザ:redmine、パスワード:redmineを作成しておきます。
作業はpostgresユーザで行います。

# su - postgres
$ createuser -d -P redmine
Enter password for new role:パスワード
Enter in again:パスワード(確認)
 
$ createdb redmine --owner=redmine --encoding=UTF8 --template=template0
--------------------------------------------------------
DB作成が終わったらrootに戻りましょう。
$ exit
 

●Ruby 1.9.3のインストール

# cd /usr/local/src
# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz
# tar zxvf ./ruby-1.9.3-p392.tar.gz
# cd ./ruby-1.9.3-p392
# ./configure
# make
# make install
# ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]

●Rubygems(Rubyに同梱されています)

# gem -v
1.8.23

●bundlerのインストール

# gem install bundler --no-rdoc --no-ri

Fetching: bundler-1.3.4.gem (100%)
Successfully installed bundler-1.3.4
1 gem installed

--no-rdoc --no-riはドキュメントの不要


●Redmineのインストール


公開ディレクトリ
# useradd redmine ※ユーザを作成するとpublic_htmlが自動的に作成されるようしている
# chmod 755 /home/redmine
# chmod 775 /home/redmine/public_html
 
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/76867/redmine-2.3.0.tar.gz
http://rubyforge.org/frs/?group_id=1850で確認してください。

# tar zxvf redmine-2.3.0.tar.gz 
# mv ./redmine-2.3.0/* /home/redmine/public_html/
 
DBへの接続設定
# cp /home/redmine/public_html/config/database.yml.example /home/redmine/public_html/config/database.yml
 
# vi /home/redmine/public_html/config/database.yml
コメント
#production:
#  adapter: mysql
#  database: redmine
#  host: localhost
#  username: root
#  password:
#  encoding: utf8
追記
production:
  adapter: postgresql
  database: redmine #DB名
  host: localhost #接続先
  username: redmine #DBユーザ
  password: "redmine" #ユーザパスワード
 
Mailの設定
# cp /home/redmine/public_html/config/configuration.yml.example /home/redmine/public_html/config/configuration.yml
 
# vi /home/redmine/public_html/config/configuration.yml
 
ここではlocalhost上のSMTPサーバを利用した例です。
詳しくはRedmine.JP様のページを参考にして頂くとわかりやすいと思います。
 
下の方にproduction:だけが記述されている部分があるのでそこへ追記します。(わかりずらい)

# 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.com

ちなみに自社では自前のメールサーバがありLAN上から参照できます。なのでこんな感じです。
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: "10.1.1.190"
      port: 25
      domain: 自社ドメイン

●Gem pgのインストール

PostgreSQLはソースからインストールしたのでパスを読み込んでから実行する必要がある。

# export PATH=$PATH:/usr/local/pgsql/bin
# gem install pg -- --with-pg-dir=/usr/local/pgsql/ --with-pg-lib=/usr/local/pgsql/lib/ --with-pg-include=/usr/local/pgsql/include/ --no-rdoc --no-ri

Fetching: pg-0.15.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed pg-0.15.0
1 gem installed
Installing ri documentation for pg-0.15.0...
Installing RDoc documentation for pg-0.15.0...


●その他Gemパッケージのインストール

Redmineで必要なパッケージを一括でインストールします。(Gemfileに記載されている

2.3よりDBアダプタはdatabase.ymlを参照して適切なアダプタがインストールされるようである。従ってdatabase.ymlには使用しないアダプター名は指定しないようにしておきます。

database.yml.sampleにはproduction:以外の記述があるため注意です。production以外はコメントにするのがいいでしょう。

# cd /home/redmine/public_html/
# bundle install --without development test

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.4) 
Using i18n (0.6.1) 
Using multi_json (1.7.2) 
Using activesupport (3.2.13) 
Using builder (3.0.0) 
Using activemodel (3.2.13) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.6) 
Using sprockets (2.2.2) 
Using actionpack (3.2.13) 
Using mime-types (1.21) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.5.3) 
Using actionmailer (3.2.13) 
Using arel (3.0.2) 
Using tzinfo (0.3.37) 
Using activerecord (3.2.13) 
Using activeresource (3.2.13) 
Using bundler (1.3.4) 
Using coderay (1.0.9) 
Using rack-ssl (1.3.3) 
Using json (1.7.7) 
Using rdoc (3.12.2) 
Using thor (0.18.0) 
Using railties (3.2.13) 
Using jquery-rails (2.0.3) 
Using net-ldap (0.3.1) 
Using pg (0.15.0) 
Using ruby-openid (2.1.8) 
Using rack-openid (1.3.1) 
Using rails (3.2.13) 
Using rmagick (2.13.2) 
Your bundle is complete!
Gems in the groups development and test were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.


●初期設定およびテーブル作成

# cd /home/redmine/public_html/

# bundle exec rake generate_secret_token
# RAILS_ENV=production bundle exec rake db:migrate

●Passengerのインストール


# 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.1.2.gem (100%)
Fetching: passenger-3.0.19.gem (100%)
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-1.1.2
Successfully installed passenger-3.0.19
3 gems installed


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

Apacheはソースからインストールしたのでapxs2、path環境変数を設定する必要がある

# export APXS2=/usr/local/apache/bin/apxs
# export PATH=/usr/local/apache/bin:$PATH

# passenger-install-apache2-module

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

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.

 
Enterを押します。


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

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/local/apache/bin/httpd
 * Apache 2 development headers... found at /usr/local/apache/bin/apxs
 * Apache Portable Runtime (APR) development headers... found at /usr/local/apache/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/local/apache/bin/apu-1-config

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

Compiling and installing Apache 2 module...




途中でnot foundが出たら解決して再度実行




--------------------------------------------
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.9.1/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19
   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.

Enterを押します。



--------------------------------------------
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
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public    
     
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
     
   

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.9.1/gems/passenger-3.0.19/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com

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


●Apache用設定ファイルの新規作成

設定ファイルの書き出し
# passenger-install-apache2-module --snippet > /usr/local/apache/conf/extra/passnger.conf
 
HTTPヘッダ削除、Passengerチューニングをpassnger.confへ(任意)
# vi /usr/local/apache/conf/extra/passnger.conf

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.19
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のチューニング設定

※詳しくはhttp://www.modrails.com/documentation/Users%20guide%20Apache.html

 
編集が終わったらhttpd.confでpassnger.confをIncludeさせるようにします。
# vi /usr/local/apache/conf/httpd.conf
最後にでも追記
Include conf/extra/passnger.conf
 
ついでにDocumentRootをRedmineとする(http://IPアドレスで閲覧できる)
DocumentRoot "/home" → "/home/redmine/public_html/public"
 
Apacheのユーザが書き込みできるように設定してApacheを再起動
# chown -R daemon:daemon /home/redmine
# /usr/local/apache/bin/apachectl restart
 
これでIPアドレスによる接続はできると思いますので、初期設定のadmin(パスワード:admin)でログインしてみましょう。
※アクセスできない場合・・・ディレクトリパーミッション、selinuxOFF、iptablesで80ポート開放等をチェックしてみましょう。



ログイン後、上記メニューの「管理」をクリックするとロール、トラッカー、チケットのステータス、ワークフローが設定されていないのでデフォルト設定をロードするよう勧められますのでJapaese(日本語)を選択してデフォルト設定をロードします。




●ログレベル・ログローテーション

# cp /home/redmine/public_html/config/additional_environment.rb.example /home/redmine/public_html/config/additional_environment.rb

ログレベル# vi /home/redmine/public_html/config/additional_environment.rb
config.log_level = :warn

ログファイルのローテーション
1週間ごとにファイルを切り替え12世代(約3ヶ月)履歴を残すようにしています。

# vi /etc/logrotate.d/redmine

/home/redmine/public_html/log/*.log {
  rotate 12
  weekly
  missingok
  notifempty
  copytruncate

  postrotate
      /bin/kill -USR1 `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
  endscript

}

 
Apache再起動
# /usr/local/apache/bin/apachectl restart
 

●EPELレポジトリの調整

標準レポジトリのパッケージがEPELレポジトリのパッケージで上書きされないよう基本的に無効化
 
# vi /etc/yum.repos.d/epel.repo
enabled=1のところを=0に変更
 
※yum-plugin-prioritiesをインストールしてEPELレポジトリのプライオリティを下げておくのもよい(以前RPMforgeリポジトリ導入で書いたので参考にして頂ければと思います)


●テーマを追加

Redmine.JP様で公開されている日本語環境でRedmineの画面を見やすくすることを目的としたテーマ「farend fancy」(farend basicの派生テーマ)を使えるようにします。

# cd /home/redmine/public_html

# git clone git://github.com/farend/redmine_theme_farend_fancy.git public/themes/farend_fancy

Redmineの管理画面から「管理」>「設定」>「表示」→テーマを Farend fancyに変更します。保存ボタンを押すのを忘れずに!
 
 
<参考サイト>
本家Redmine:http://www.redmine.org/projects/redmine/wiki/RedmineInstall
Redmine.JP:http://blog.redmine.jp/articles/2_3/installation_centos/

2012年9月18日火曜日

Redmine2.1インストールしてみた

先日リリースされたRedmine2.1新規インストールしてみた。ついでにDBも先日リリースされたPostgreSQL9.2です。尚、OSはCentOS6.3(x86)です。

以前CentOS6にRedmine2.0+PostgreSQL9.1を構築した手順と全く同じ要領で問題ありませんでした。

こちらを参考にして頂けると幸いです。
http://stdman.blogspot.jp/2012/05/centos6redmine20.html

PostgreSQL9.2ではcreateuserの仕様が若干変わったようで、オプションでロールを割り当てるようです。

ちなみにredmine用ユーザ作成時に、-dでDB作成可、-Pでパスワード作成


$ createuser redmine -d -P
Enter password for new role: ********
Enter it again: ********

オプションはこんな感じです。

$ createuser --help
createuser creates a new PostgreSQL role.

Usage:
  createuser [OPTION]... [ROLENAME]

Options:
  -c, --connection-limit=N  connection limit for role (default: no limit)
  -d, --createdb            role can create new databases
  -D, --no-createdb         role cannot create databases (default)
  -e, --echo                show the commands being sent to the server
  -E, --encrypted           encrypt stored password
  -i, --inherit             role inherits privileges of roles it is a
                            member of (default)
  -I, --no-inherit          role does not inherit privileges
  -l, --login               role can login (default)
  -L, --no-login            role cannot login
  -N, --unencrypted         do not encrypt stored password
  -P, --pwprompt            assign a password to new role
  -r, --createrole          role can create new roles
  -R, --no-createrole       role cannot create roles (default)
  -s, --superuser           role will be superuser
  -S, --no-superuser        role will not be superuser (default)
  -V, --version             output version information, then exit
  --interactive             prompt for missing role name and attributes rather
                            than using defaults
  --replication             role can initiate replication
  --no-replication          role cannot initiate replication
  -?, --help                show this help, then exit

Connection options:
  -h, --host=HOSTNAME       database server host or socket directory
  -p, --port=PORT           database server port
  -U, --username=USERNAME   user name to connect as (not the one to create)
  -w, --no-password         never prompt for password
  -W, --password            force password prompt
 
 
Redmine 2.1よりチケットやWikiに添付ファイルのサムネイル画像が表示できるようになった。
Redmine_ROOT/tmp/thumbails 書込み権限が必要ですので注意
 

2012年6月8日金曜日

Redmine2.0.1から2.0.2へアップデート

Ruby on Railsの脆弱性が見つかったようでRedmine2.0.2がリリース

Redmine2.0.1を構築したばかりなのに・・・構築はこちらです
でもまだ運用至っていないので、アップデートしちゃいます。
尚、プラグインや外部テーマは一切使用していない状態です。

環境を簡単に説明すると
CentOS6.2(x86)
Apache 2.2.22+Passenger
PostgreSQL9.1.3
※Apache, PostgreSQLはソースからインストール

http://www.redmine.org/projects/redmine/wiki/RedmineUpgradeを参考にアップデート


●Redmine2.0.1のバックアップ

Redmineソース
# mv /home/redmine/public_html /home/redmine/public_html_2.0.1

データベース(PostgreSQL9.1)
データベース名:redmine
ユーザー名:redmine
# /usr/local/pgsql/bin/pg_dump -U redmine -Fc redmine > /home/redmine/public_html_2.0.1/v201_db_`date +%Y%m%d`.dump

v201_db_今日の日付(db_20120608.dump)というスタイルでバックアップファイルが作成されます。


●Redmine2.0.2の配置

ディレクトリの作成
# mkdir /home/redmine/public_html
# chmod 775 /home/redmine/public_html

RedmineはTarボールを利用
ダウンロード先はhttp://rubyforge.org/frs/?group_id=1850を参照
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/76189/redmine-2.0.2.tar.gz
# tar zxvf redmine-2.0.2.tar.gz
# mv ./redmine-2.0.2/* /home/redmine/public_html/

設定ファイル等のコピー(プラグインは考慮していない)
# cp /home/redmine/public_html_2.0.1/config/database.yml /home/redmine/public_html/config/

# cp /home/redmine/public_html_2.0.1/config/configuration.yml /home/redmine/public_html/config/

ログ制御
# cp /home/redmine/public_html_2.0.1/config/additional_environment.rb /home/redmine/public_html/config/

添付ファイル # cp /home/redmine/public_html_2.0.1/files/* /home/redmine/public_html/files/

追加したテーマ
# cp -R /home/redmine/public_html_2.2.0/public/themes/farend_fancy /home/redmine/public_html/public/themes/

passengerで稼働しているためApacheユーザーに権限を与える
# chown -R daemon:daemon /home/redmine/public_html

Gemパッケージ(Railsが3.2.5になります)
# cd /home/redmine/public_html
# bundle install --without development test mysql sqlite →DBがPostgreSQLの場合
# bundle install --without development test postgresql sqlite →DBがMySQLの場合
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.3.6) 
Installing activesupport (3.2.5) 
Using builder (3.0.0) 
Installing activemodel (3.2.5) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Installing actionpack (3.2.5) 
Using mime-types (1.18) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Installing actionmailer (3.2.5) 
Using arel (3.0.2) 
Using tzinfo (0.3.33) 
Installing activerecord (3.2.5) 
Installing activeresource (3.2.5) 
Using bundler (1.1.4) 
Using coderay (1.0.6) 
Using json (1.7.3) 
Using net-ldap (0.3.1) 
Using pg (0.13.2) 
Using rack-ssl (1.3.2) 
Using rdoc (3.12) 
Installing thor (0.15.2) 
Installing railties (3.2.5) 
Installing rails (3.2.5) 
Using prototype-rails (3.2.1) 
Using ruby-openid (2.1.8) 
Using rack-openid (1.3.1) 
Using rmagick (2.13.1) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

# rake generate_secret_token
# rake db:migrate RAILS_ENV=production 
# rake redmine:plugins:migrate RAILS_ENV=production
# rake tmp:cache:clear
# rake tmp:sessions:clear


passengerで稼働しているためApacheユーザーに権限を与える
# chown -R daemon:daemon /home/redmine/public_html


Apacheの再起動

Redmine 2.0.2 + PostgreSQL

以上で完了

※2.1系、2.2系でも同じ手順で大丈夫と思われます。

<PostgreSQL 参考>
ちなみにバックアップしたデータベースの復元方法です。


データベース名:redmine
ユーザー名:user1
バックアップ名:v202_dbbackup.dump


1.空のデータベースを作成

原則としてrootでは作業できませんので、PostgreSQLを運用しているユーザで行います。(私はpostgresというユーザで運用しています)

# su - postgres

$ createdb redmine --owner=user1 --encoding=UTF8 --template=template0


2.復元

[postgres@localhost]$ pg_restore -d redmine ./v202_dbbackup.dump

これでOKです。
 



2012年5月29日火曜日

CentOS6にRedmine2.0&PostgreSQL9.1

Redmine+PosgtreSQL+Apache+Passenger

  • Redmine:2.0.1
  • OS:  CentOS-6.2(x86) Minimal構成
  • Web: Apache-2.2.22(ソースから) Passenger実行
  • DB:  PostgreSQL-9.1.3(ソースから)
  • Ruby: Ruby1.9.3-p194(ソースから)
  • Rails: 3.2.3(Ruby同梱)
Redmineは/home/redmine/public_html以下に配置します。
※ApacheのUserDirを有効にする
 
2012/06/05 redmine 2.0.2がリリース→2.0.1を2.0.2へのアップデートはこちら
2012/06/19 redmine 2.0.3がリリース(以下と同様の手順でOK)

OSのインストール

ここでは構築手順を割愛させて頂きますが以下で構築したものをベースにしております。
VMwareにテキストモードでインストールしたのもですが多少は参考になるかと思います。
http://stdman.blogspot.jp/2011/12/centos6.html

構成内容
・IPv6:OFF
・パッケージ群:Base,Development Tools
・有効サービス:crond,iptables,network,ntpd,postfix,rsyslog,sshd,cpuspeed,irqbalance
・FireWall:enable → customでSSH,WWW(HTTP)をON,Forward設定なし

●必要パッケージやリポジトリをインストール

Rubyのビルドで必要なEPELリポジトリのインストール
http://ftp.riken.jp/Linux/fedora/epel/6/i386/repoview/epel-release.htmlからRPMのダウンロード先リンクを取得します。
 
# rpm -Uvh http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-7.noarch.rpm

Retrieving http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-7.noarch.rpm
warning: /var/tmp/rpm-tmp.ZZztWP: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

EPELレポジトリのGPGキーのインポート
# rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
 
EPELレポジトリのGPGキーの確認
# rpm -q 'gpg-pubkey-*' --qf '%{name} -> %{summary}\n'

gpg-pubkey - >  gpg(CentOS-6 Key (CentOS 6 Official Signing Key) )
gpg-pubkey - >  gpg(EPEL (6) )

開発パッケージが必要になりますのでインストールください。
# yum groupinstall "Development Tools"
# yum install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel ImageMagick ImageMagick-devel
※libyamlとlibyaml-develがEPELレポジトリから取得されました
 

●Apacheのインストール

ソースからインストールしています。
詳しくはこちらのインストールを参考にして頂ければと思います。

/usr/local/apacheにインストール、UserDir有効
 

●PostgreSQLのインストール

ソースからインストールしています。
詳しくはこちらのインストールを参考にして頂ければと思います。
/usr/local/pgsqlにインストール、dataはpgsqlの直下
またPL/pgsqlが必要ですが9.0以降はデフォルトでインストールされます。
 
DB名:redmine、ユーザ:redmine、パスワード:redmineを作成しておきます。
 
--------------------------------------------------------
postgresqlのユーザで実行
$ createuser -P redmine
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
 
allowed to create more new roles? (y/n) n
 
$ createdb redmine --owner=redmine --encoding=UTF8 --template=template0
--------------------------------------------------------
DB作成が終わったらrootに戻りましょう。
$ exit
 

●Ruby 1.9.3のインストール

# cd /usr/local/src
# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
# tar zxvf ./ruby-1.9.3-p194.tar.gz
# cd ./ruby-1.9.3-p194
# ./configure
# make
# make install
# ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]

●Rubygems(Rubyに同梱されています)

# gem -v
1.8.23

●bundlerのインストール

# gem install bundler --no-rdoc --no-ri
Fetching: bundler-1.1.4.gem (100%)
Successfully installed bundler-1.1.4
1 gem installed

●Redmineのインストール


公開ディレクトリ
# useradd redmine ※ユーザを作成するとpublic_htmlが自動的に作成されるようしている
# chmod 755 /home/redmine
# chmod 775 /home/redmine/public_html
 
# cd /usr/local/src
# wget http://rubyforge.org/frs/download.php/76154/redmine-2.0.1.tar.gz
http://rubyforge.org/frs/?group_id=1850で確認してください。

# tar zxvf redmine-2.0.1.tar.gz 
# mv ./redmine-2.0.1/* /home/redmine/public_html/
 
DBへの接続設定
# cp /home/redmine/public_html/config/database.yml.example /home/redmine/public_html/config/database.yml
 
# vi /home/redmine/public_html/config/database.yml
コメント
#production:
#  adapter: mysql
#  database: redmine
#  host: localhost
#  username: root
#  password:
#  encoding: utf8
追記
production:
  adapter: postgresql
  database: redmine #DB名
  host: localhost #接続先
  username: redmine #DBユーザ
  password: "redmine" #ユーザパスワード
 
Mailの設定
# cp /home/redmine/public_html/config/configuration.yml.example /home/redmine/public_html/config/configuration.yml
 
# vi /home/redmine/public_html/config/configuration.yml
 
ここではlocalhost上のSMTPサーバを利用した例です。
詳しくはRedmine.JP様のページを参考にして頂くとわかりやすいと思います。
 
下の方にproduction:だけが記述されている部分があるのでそこへ追記します。(わかりずらい)

# 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.com

ちなみに自社では自前のメールサーバがありLAN上から参照できます。なのでこんな感じです。
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: "10.1.1.190"
      port: 25
      domain: 自社ドメイン

●Gem pgのインストール

PostgreSQLはソースからインストールしたのでパスを読み込んでから実行する必要がある。

# export PATH=$PATH:/usr/local/pgsql/bin
# gem install pg -- --with-pg-dir=/usr/local/pgsql/ --with-pg-lib=/usr/local/pgsql/lib/ --with-pg-include=/usr/local/pgsql/include/ --no-rdoc --no-ri
Building native extensions.  This could take a while...
Successfully installed pg-0.13.2
1 gem installed
Installing ri documentation for pg-0.13.2...
Installing RDoc documentation for pg-0.13.2...

redmine 2.0.3ではpg-0.14.0になります。

●その他Gemパッケージのインストール

Redmineで必要なパッケージを一括でインストールします。(Gemfileに記載されている
ここではDBにPostgreSQLを利用するため使わないMySQLやSQLLiteは不要とします。

# bundle install --without development test mysql sqlite
Could not locate Gemfile
 
あれ?Gemfileが見つからない?
 
探してみると・・・
# find / -name Gemfile

/usr/local/lib/ruby/gems/1.9.1/gems/prototype-rails-3.2.1/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/rack-cache-1.2/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1.4/lib/bundler/templates/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/multi_json-1.3.6/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/mail-2.4.4/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/tilt-1.3.3/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/arel-3.0.2/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/rack-test-0.6.1/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/journey-1.0.3/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12/test/stub/rails_apps/3.0/empty/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/json-1.7.3/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/generators/rails/app/templates/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/generators/rails/plugin_new/templates/Gemfile
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.3/guides/code/getting_started/Gemfile
/home/redmine/public_html/Gemfile
 
Redmineのルートディレクトリにあった・・・ということでルートディレクトリに移動してもう一度

# cd /home/redmine/public_html/
# bundle install --without development test mysql sqlite
Fetching gem metadata from http://rubygems.org/.......
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.3.6) 
Using activesupport (3.2.3) 
Using builder (3.0.0) 
Using activemodel (3.2.3) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.3) 
Using actionpack (3.2.3) 
Using mime-types (1.18) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.3) 
Using arel (3.0.2) 
Using tzinfo (0.3.33) 
Using activerecord (3.2.3) 
Using activeresource (3.2.3) 
Using bundler (1.1.4) 
Using coderay (1.0.6) 
Using json (1.7.3) 
Using net-ldap (0.3.1) 
Using pg (0.13.2) 
Installing rack-ssl (1.3.2) 
Using rdoc (3.12) 
Installing thor (0.14.6) 
Installing railties (3.2.3) 
Installing rails (3.2.3) 
Installing prototype-rails (3.2.1) 
Installing ruby-openid (2.1.8) 
Installing rack-openid (1.3.1) 
Installing rmagick (2.13.1) with native extensions 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
 
<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!

redmine 2.0.2ではrails3.2.5になります。
redmine 2.0.3ではrails3.2.6になります。

●初期設定およびテーブル作成

# cd /home/redmine/public_html/

# rake generate_secret_token
rake db:migrate RAILS_ENV=production

●Passengerのインストール


# 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.12.gem (100%)
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-1.0.0
Successfully installed passenger-3.0.12
3 gems installed

redmine 2.0.3ではrails3.0.15になります。

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

Apacheはソースからインストールしたのでapxs2、path環境変数を設定する必要がある

# export APXS2=/usr/local/apache/bin/apxs
# export PATH=/usr/local/apache/bin:$PATH

# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.12.
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.
 
Enterで進めていく

途中でnot foundが出たら解決して再度実行




Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/
 
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

●Apache用設定ファイルの新規作成

設定ファイルの書き出し
# passenger-install-apache2-module --snippet > /usr/local/apache/conf/extra/passnger.conf
 
HTTPヘッダ削除、Passengerチューニングをpassnger.confへ(任意)
# vi /usr/local/apache/conf/extra/passnger.conf

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
 
編集が終わったらhttpd.confでpassnger.confをIncludeさせるようにします。
# vi /usr/local/apache/conf/httpd.conf
最後にでも追記
Include conf/extra/passnger.conf
 
ついでにDocumentRootをRedmineとする
DocumentRoot "/home" → "/home/redmine/public_html/public"
 
Apacheのユーザが書き込みできるように設定してApacheを再起動
# chown -R daemon:daemon /home/redmine
# /usr/local/apache/bin/apachectl restart
 
これでIPアドレスによる接続はできると思いますので、初期設定のadmin(パスワード:admin)でログインしてみましょう。
※アクセスできない場合・・・ディレクトリパーミッション、selinuxOFF、iptablesで80ポート開放等をチェックしてみましょう。



ログイン後、上記メニューの「Administration」をクリックするとロール、トラッカー、チケットのステータス、ワークフローが設定されていないのでデフォルト設定をロードするよう勧められますので日本語を選択してロードしましょう。



一番下にある「Information」をクリックします。


Ver 2.0.1です。

Ver 2.0.2です。


●ログレベル・ログローテーション

デフォルトではデバックとなるため大量のログが吐き出されるので調整します。またローテーション設定してファイルが肥大化しないようします。
# cp /home/redmine/public_html/config/additional_environment.rb.example /home/redmine/public_html/config/additional_environment.rb

# vi /home/redmine/public_html/config/additional_environment.rb
config.logger = Logger.new(config.log_path, 2, 1000000)
config.logger.level = Logger::INFO
 
Apache再起動
# /usr/local/apache/bin/apachectl restart
 
あれ?ブラウザを見るとメソッドがないと怒られてしまう・・・とりあえずこれは後回しにしてコメントにしておこう
#config.logger = Logger.new(config.log_path, 2, 1000000)

#config.logger.level = Logger::INFO
 
ググってみたらログレベルは以下の記述方法が見つかりました。
config.log_level = :warn

ということでこの1行のみ記述しました。 
ちなみにレベルはunknown、error、fatal、warn、info、debugがあります。

仕方がないログのローテーションはOSのlogrotateを代用することにします。
ここでは1週間ごとにファイルを切り替え12世代(約3ヶ月)履歴を残すようにしています。
※Apacheが/usr/local/apacheにインストールされている場合です。

# vi /etc/logrotate.d/redmine

/home/redmine/public_html/log/*.log {
  rotate 12
  weekly
  missingok
  notifempty
  copytruncate

  postrotate
      /bin/kill -USR1 `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
  endscript

}
 

●EPELレポジトリの調整

標準レポジトリのパッケージがEPELレポジトリのパッケージで上書きされないよう基本的に無効化
 
# vi /etc/yum.repos.d/epel.repo
enabled=1のところを=0に変更
 
※yum-plugin-prioritiesをインストールしてEPELレポジトリのプライオリティを下げておくのもよい(以前RPMforgeリポジトリ導入で書いたので参考にして頂ければと思います)


●テーマを追加

Redmine.JP様で公開されている日本語環境でRedmineの画面を見やすくすることを目的としたテーマ「farend fancy」(farend basicの派生テーマ)を使えるようにします。

インストール方法は以下の2パターンからできます。

①gitレポジトリからの場合
# cd /home/redmine/public_html
# git clone git://github.com/farend/redmine_theme_farend_fancy.git public/themes/farend_fancy

Initialized empty Git repository in /home/redmine/public_html/public/themes/farend_fancy/.git/
remote: Counting objects: 195, done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 195 (delta 75), reused 169 (delta 49)
Receiving objects: 100% (195/195), 49.21 KiB, done.
Resolving deltas: 100% (75/75), done.


②アーカイブからの場合
https://github.com/farend/redmine_theme_farend_fancy/downloadsからtar.gzをダウンロードして/usr/local/srcへ配置します。 
# cd /usr/local/src/
# tar zxvf farend-redmine_theme_farend_fancy-a77f7cd.tar.gz
# cp -R ./farend-redmine_theme_farend_fancy-a77f7c  /home/redmine/public_html/public/themes/farend_fancy

Apache再起動
# /usr/local/apache/bin/apachectl restart
 Redmineの管理画面から「管理」>「設定」>「表示」→テーマを Farend fancyに変更します。保存ボタンを押すのを忘れずに!
 

とりあえずこんなもんで構築は終わりでしょう。でも随分と構築が楽になりましたね!
 
<参考サイト>
本家Redmine:http://www.redmine.org/projects/redmine/wiki/RedmineInstall
Redmine.JP:http://blog.redmine.jp/articles/redmine-2_0-installation_centos/

Google検索