ティーブレイク:水戸周辺と育児と仕事

メニュー

サイト情報



メモ

写メールBBS


どきどきにて。
写メールBBSへ

ログイン
ユーザ名:

パスワード:


Lost Password?

Register now!



CentOS 4.4にRubyを入れるとこから

最新バージョンの Ruby の導入より
参考

新規に RPMforge リポジトリを rpm でインストール

$ sudo wget \
  http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
$ sudo rpm -Uhv rpmforge-release-0.3.6-1.el4.rf.i386.rpm

デフォルトでは有効にならないように設定ファイルを修正

$ sudo vi /etc/yum.repos.d/rpmforge.repo
enabled = 1
    ↓
enabled = 0           ←デフォルトでは有効にしない

 次に RPM の署名を検証するためのキーを導入します。

$ sudo wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
RPMforge のリポジトリを使いたい場合は以下のように「--enablerepo=rpmforge」をつけます。
ちなみに以下は、RPMforge のものも含めたパッケージのリストを表示します。
$ sudo yum --enablerepo=rpmforge list


checkinstall の導入

$ sudo yum --enablerepo=rpmforge install checkinstall


最新バージョンの Ruby の導入

 CentOS 4.4 の標準パッケージの Ruby のバージョンは 1.8.1なので最新バージョンを
 checkinstall を使って RPM 化してからインストールする。


$ rpm -q ruby
ruby-1.8.1-7.EL4.8
$ sudo yum remove ruby-libs


最新バージョンの取得とビルド

$ sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
$ sudo tar zxvf ruby-1.8.6.tar.gz 
$ cd ruby-1.8.6


 Ruby をビルドします。checkinstall を使って RPM として管理するので、
「--prefix=/usr」をつけてインストール先を /usr にしています。

$ sudo su
# ./configure --prefix=/usr
config.status: creating Makefile
# make

Ruby の RPM 化とインストール

# /usr/sbin/checkinstall  --fstrans=no

checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: y

 続いてパッケージタイプを聞かれます。RPM なので r を入力します。

Preparing package documentation...OK

Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? R
 パッケージの詳細の入力を求められます。何も入力せずに Enter 。
Please write a description for the package.
End your description with an empty line or EOF.
>>
 最後にパッケージの内容の確認がでます。ここで Enter を押すと RPM の作成処理が始まります。
**************************************
**** RPM package creation selected ***
**************************************

This package will be built according to these values: 

1 -  Summary: [ Package created with checkinstall 1.6.0 ]
2 -  Name:    [ ruby ]
3 -  Version: [ 1.8.6 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Applications/System ]
7 -  Architecture: [ x86_64 ]
8 -  Source location: [ ruby-1.8.6 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ ruby ]

Enter a number to change any of them or press ENTER to continue: 
..
**********************************************************************

 Done. The new package has been saved to

 /usr/src/redhat/RPMS/x86_64/ruby-1.8.6-1.x86_64.rpm
 You can install it in your system anytime using: 

      rpm -i ruby-1.8.6-1.x86_64.rpm

**********************************************************************


 作成された RPM をインストールします。

# rpm -Uvh  /usr/src/redhat/RPMS/x86_64/ruby-1.8.6-1.x86_64.rpm

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux]


RubyGems の導入
参考

RubyGems の取得とセットアップ
 http://rubygems.org/
 http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz

$ sudo wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
$ sudo tar zxvf rubygems-0.9.4.tgz
$ cd rubygems-0.9.4

$ sudo su
以下の状態で止まります。デフォルトのパッケージドキュメントを作っていいかと聞かれます。
作ってもいいのでそのまま Enter
# /usr/sbin/checkinstall -R "ruby setup.rb"

checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.


The package documentation directory ./doc-pak does not exist. 
Should I create a default set of package docs?  [y]: 
 パッケージの詳細の入力を求められます。何も入力せずに Enter 
Preparing package documentation...OK

Please write a description for the package.
End your description with an empty line or EOF.
>> 
 最後にパッケージの内容の確認がでます。RubyGems は Ruby がなければ始まらないので、
 ruby に依存するように設定します。
**************************************
**** RPM package creation selected ***
**************************************

This package will be built according to these values:

1 -  Summary: [ Package created with checkinstall 1.6.0 ]
2 -  Name:    [ rubygems ]
3 -  Version: [ 0.9.2 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Applications/System ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ rubygems-0.9.2 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ rubygems ]

Enter a number to change any of them or press ENTER to continue: 11
  ←checkinstall 1.6.0-3 のバグのため 10 ではなく 11 を指定
Enter the additional requirements:
>> ruby
 再び以下のように表示されます。ここで Enter を押すと RPM の作成が開始されます。
**************************************
**** RPM package creation selected ***
**************************************

This package will be built according to these values:

1 -  Summary: [ Package created with checkinstall 1.6.0 ]
2 -  Name:    [ rubygems ]
3 -  Version: [ 0.9.2 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ Applications/System ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ rubygems-0.9.2 ]
9 -  Alternate source location: [  ]
10 - Requires: [ ruby ]
11 - Provides: [ rubygems ]

Enter a number to change any of them or press ENTER to continue:


**********************************************************************

 Done. The new package has been saved to

 /usr/src/redhat/RPMS/x86_64/rubygems-0.9.4-1.x86_64.rpm
 You can install it in your system anytime using: 

      rpm -i rubygems-0.9.4-1.x86_64.rpm

**********************************************************************

# rpm -Uvh /usr/src/redhat/RPMS/x86_64/rubygems-0.9.4-1.x86_64.rpm
# gem --version
0.9.4


CentOS 4のyumでcentosplusを有効にする


/etc/yum.repos.d/CentOS-Base.repo
enabled=0を1に変え


MySQLのバージョンを5にアップグレード

参考


yum --enablerepo=centosplus upgrade mysql*
yum --enablerepo=centosplus install mysql-server-5*


立ち上げと設定など

$ sudo /sbin/chkconfig mysqld on
$ sudo /etc/init.d/mysqld start
MySQL データベースを初期化中:                              [  OK  ]
MySQL を起動中:                                            [  OK  ]

redmine用DBを作る
$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.48 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database redmine;
Query OK, 1 row affected (0.00 sec)

mysql> exit



railsを入れるのを忘れてたので入れる
(> gem install rails --include-dependenciesならY入れないでよかったみたい)

$ sudo gem install rails
Bulk updating Gem source index for: http://gems.rubyforge.org
Install required dependency rake? [Yn]  Y
Install required dependency activesupport? [Yn]  Y
Install required dependency activerecord? [Yn]  Y
Install required dependency actionpack? [Yn]  Y
Install required dependency actionmailer? [Yn]  Y
Install required dependency actionwebservice? [Yn]  Y
Successfully installed rails-1.2.4
Successfully installed rake-0.7.3

現在のSubversionの設定をみる
more /etc/httpd/conf.d/subversion.conf
<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
SVNAutoversioning on
AuthzSVNAccessFile /var/www/svn/.htsvn_access
      AuthType Basic
      AuthName "Subversion"
      AuthUserFile /var/www/svn/.htpasswd
      Require valid-user
</Location>


レポジトリを作成

sudo svnadmin create --fs-type fsfs /var/www/svn/repos10
sudo chown -R apache:apache
sudo chown -R apache:apache repos10
sudo more /var/www/svn/.htpasswd
sudo vi /var/www/svn/.htsvn_access


書き込みの為の設定(最後を追加)

$ more /var/www/svn/.htsvn_access
[groups]
manager = tomoko
dev = xxx,xxxx,xxxxx
[/]
* = r
[repos10:/]
* = r
@manager = rw
@dev = rw


いよいよredmineを入れる

$ cd /usr/local/src
$ sudo wget http://rubyforge.org/frs/download.php/22783/redmine-0.5.1.tar.gz
$ sudo tar zxvf redmine-0.5.1.tar.gz 
$ cd /usr/local
$ sudo ln -s /usr/local/src/redmine-0.5.1 ./redmine
$ cd redmine/
$ cd config/
$ sudo cp database.yml.example database.yml
$ more database.yml
# MySQL (default setup).  Versions 4.1 and 5.0 are recommended.
#
# Get the fast C bindings:
#   gem install mysql
#   (on OS X: gem install mysql -- --include=/usr/local/lib)
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: root
  password:
 .....
$ cd ..
$ ls
Rakefile  app/  components/  config/  db/  doc/  extra/  files/  lang/ \
  lib/  log/  public/  script/  test/  tmp/  vendor/
$ sudo rake db:migrate RAILS_ENV="production"
(in /usr/local/src/redmine-0.5.1)
rake aborted!
No such file or directory - /tmp/mysql.sock

(See full trace by running task with --trace)

mysqlのソケットの場所が違ってた。
$ sudo vi config/database.yml
production:に
  socket: /var/lib/mysql/mysql.sock←追加

$ sudo rake db:migrate RAILS_ENV="production"
(in /usr/local/src/redmine-0.5.1)
== Setup: migrating =================================================
-- create_table("attachments", {:force=>true})
   -> 0.1205s

$ sudo rake load_default_data RAILS_ENV="production"
(in /usr/local/src/redmine-0.5.1)

Select language: bg, de, en, es, fr, it, ja, nl, pt, pt-br, sv, zh [en] ja
====================================
Loading default configuration data for language: ja


立ち上げ
$ sudo ruby script/server -e production
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-10-10 14:49:58] INFO  WEBrick 1.3.1
[2007-10-10 14:49:58] INFO  ruby 1.8.6 (2007-03-13) [x86_64-linux]
[2007-10-10 14:49:58] INFO  WEBrick::HTTPServer#start: pid=8132 port=3000

ブラウザでアクセス
http://example.com:3000/
最初はadmin,adminで登録されている。
adminで入りmyaccount設定で日本語表示にする


第2回 環境構築/redMineのインストール・初期設定の途中
参考
これも参考にした(http://d.hatena.ne.jp/nekoruri/20070616/1181998415)

うまくリポジトリが表示されないのはSubversionが古いから!
Subversionのバージョンアップが必要

$ sudo yum list|grep subversion
subversion.x86_64                        1.1.4-2.ent            installed       
subversion-devel.x86_64                  1.1.4-2.ent            base            
subversion-perl.x86_64                   1.1.4-2.ent            base            
$ sudo yum list|grep mod_dav_svn
mod_dav_svn.x86_64                       1.1.4-2.ent            installed       

$ sudo rpm -Uvh apr-0.9.12-2.x86_64.rpm apr-util-0.9.12-1.x86_64.rpm
Preparing...                ########################################### [100%]
   1:apr                    ########################################### [ 50%]
   2:apr-util               ########################################### [100%]
$ sudo yum list|grep apr
apr.x86_64                               0.9.12-2               installed       
apr-util.x86_64                          0.9.12-1               installed       
apr.i386                                 0.9.4-24.5.c4.2        base            
apr.x86_64                               0.9.4-24.5.c4.2        base            
apr-devel.x86_64                         0.9.4-24.5.c4.2        base            
apr-util.x86_64                          0.9.4-21               base            
apr-util-devel.x86_64                    0.9.4-21               base     
       
$ sudo rpm -Uvh subversion-1.4.4-1.rhel4.x86_64.rpm
エラー: Failed dependencies:
        subversion = 1.1.4-2.ent is needed by (installed) mod_dav_svn-1.1.4-2.ent.x86_64
$ sudo rpm -Uvh 
$ sudo yum list|grep mod_dav_svn
mod_dav_svn.x86_64                       1.1.4-2.ent            installed       
$ sudo rpm -Uvh mod_dav_svn-1.4.4-1.rhel4.x86_64.rpm
エラー: Failed dependencies:
        subversion = 1.4.4-1 is needed by mod_dav_svn-1.4.4-1.x86_64

一個ずつだとエラーがでるのでいっぺんに入れた

$ sudo rpm -Uvh mod_dav_svn-1.4.4-1.rhel4.x86_64.rpm subversion-1.4.4-1.rhel4.x86_64.rpm
Preparing...                ########################################### [100%]
   1:subversion             ########################################### [ 50%]
   2:mod_dav_svn 警告: /etc/httpd/conf.d/subversion.conf created as \
           /etc/httpd/conf.d/subversion.conf.rpmnew
########################################### [100%]
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]

$ sudo /etc/init.d/httpd stop
httpd を停止中:                                            [  OK  ]
$ sudo /etc/init.d/httpd start
httpd を起動中:                                            [  OK  ]
$ sudo rpm -ivh subversion-python-1.4.4-1.rhel4.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:subversion-python      ########################################### [100%]




mongrel及び新しいRedmineに。

基本的には以下を参照するがバーチャルホストは止めて
リバースプロキシで対応しようと思う。
http://redmine.jp/tech_note/install/

まずmongrelインストール

$ sudo gem install mongrel
Need to update 26 gems from http://gems.rubyforge.org
..........................
complete
Select which gem to install for your platform (x86_64-linux)
 1. mongrel 1.0.1 (mswin32)
 2. mongrel 1.0.1 (ruby)
 3. mongrel 1.0 (mswin32)
 4. mongrel 1.0 (ruby)
 5. Skip this gem
 6. Cancel installation
> 2
Install required dependency daemons? [Yn]  Y
Install required dependency fastthread? [Yn]  Y
Select which gem to install for your platform (x86_64-linux)
 1. fastthread 1.0 (ruby)
 2. fastthread 1.0 (mswin32)
 3. fastthread 0.6.4.1 (mswin32)
 4. fastthread 0.6.4.1 (ruby)
 5. Skip this gem
 6. Cancel installation
> 1
Building native extensions.  This could take a while...
Install required dependency gem_plugin? [Yn]  Y
Install required dependency cgi_multipart_eof_fix? [Yn]  Y
Building native extensions.  This could take a while...
Successfully installed mongrel-1.0.1
Successfully installed daemons-1.0.8
Successfully installed fastthread-1.0
Successfully installed gem_plugin-0.2.2
Successfully installed cgi_multipart_eof_fix-2.3
Installing ri documentation for mongrel-1.0.1...
Installing ri documentation for daemons-1.0.8...
Installing ri documentation for gem_plugin-0.2.2...
Installing ri documentation for cgi_multipart_eof_fix-2.3...
Installing RDoc documentation for mongrel-1.0.1...
Installing RDoc documentation for daemons-1.0.8...
Installing RDoc documentation for gem_plugin-0.2.2...
Installing RDoc documentation for cgi_multipart_eof_fix-2.3...

起動テスト
$ sudo /usr/bin/mongrel_rails start -e production -d -p 3000  -c /usr/local/redmine


リビジョンを上げる
trunkにある最新バージョン(リビジョン829)に変更する

$     cd tmp
$ svn checkout http://redmine.rubyforge.org/svn/trunk/
D    trunk/components
U    trunk/test/unit/user_test.rb
U    trunk/test/unit/repository_test.rb
....
$ sudo cp -r ~/tmp/trunk /usr/local/src/redmine-r829
$ sudo rm redmine
$ sudo ln -s /usr/local/src/redmine-r829 ./redmine
$ sudo cp /usr/local/src/redmine-0.5.1/config/database.yml ./
$ sudo cp /usr/local/src/redmine-0.5.1/config/environment.rb ./
$ diff database.yml database.yml.example 
11d10
<   socket: /var/lib/mysql/mysql.sock
$ sudo rake db:migrate RAILS_ENV="production"
(in /usr/local/src/redmine-r829)
== AddRolesAssignable: migrating ==============================================
-- add_column(:roles, :assignable, :boolean, {:default=>true})
   -> 0.1874s
== AddRolesAssignable: migrated (0.1876s) =====================================


......

再起動する
$ ps auxww|grep mongrel
root     31562  0.1  6.0 97704 62436 ?       S    13:53   0:03 \
  /usr/bin/ruby /usr/bin/mongrel_rails start -e production -d -p 3000 -c /usr/local/redmine
$ sudo kill 31562
$ sudo  /usr/bin/ruby /usr/bin/mongrel_rails start \
         -e production -d -p 3000 -c /usr/local/redmine



phpファイルをバイナリと認識している問題

sudo emacs lib/redmine/mime_type.rb
  module Redmine
    module MimeType
  
      MIME_TYPES = {
        'text/plain' => 'txt,php',
        'text/css' => 'css',

とか加えて再起動。「見る」リンクが追加された。

MySQLの文字コードをちゃんとしてない!

$ mysql -u root redmine
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 14
Server version: 5.0.48 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> status;
--------------
mysql  Ver 14.12 Distrib 5.0.48, for redhat-linux-gnu (x86_64) using readline 5.0

Connection id:          14
Current database:       redmine
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.48 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 6 days 1 hour 48 min 23 sec

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

mysql> show variables like "char%";
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     | 
| character_set_connection | latin1                     | 
| character_set_database   | latin1                     | 
| character_set_filesystem | binary                     | 
| character_set_results    | latin1                     | 
| character_set_server     | latin1                     | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> quit
全く設定してない状態

$ mysqldump --default-character-set=binary -u root redmine >dump.sql

文字コード変換
$ sed 's/latin1/utf8/g' dump.sql convdump.sql
$ sudo vi /etc/my.cnf 文字コード設定追加
[mysqld]
default-character-set=utf8
skip-character-set-client-handshake

$ mysql -u root redmine < convdump.sql 

で再起動するも
$ mysql -u root redmine
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 3
Server version: 5.0.48 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> status
--------------
mysql  Ver 14.12 Distrib 5.0.48, for redhat-linux-gnu (x86_64) using readline 5.0

Connection id:          3
Current database:       redmine
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.48 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    latin1
Client characterset:    utf8
Conn.  characterset:    utf8

となっていてDB自体はutf8になってくれないので、dropしてもう一度作り直しした。

$ mysql -u root 
mysql> drop database redmine;
Query OK, 42 rows affected (0.41 sec)

mysql> create database redmine;
Query OK, 1 row affected (0.01 sec)

mysql> use redmine
Database changed
mysql> status
--------------
mysql  Ver 14.12 Distrib 5.0.48, for redhat-linux-gnu (x86_64) using readline 5.0

Connection id:          5
Current database:       redmine
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.48 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 16 min 9 sec

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


redmine設定
文字コード設定(マニュアルにも間違いがあった)
以下をリポジトリのエンコーディングに指定したらうまくいった。

ISO-2022-JP, EUC-JP, UTF-8, SHIFT_JIS, WINDOWS-31J

Printer Friendly Page
Send this Story to a Friend

Previous
MacSCPluginとTracのもろもろ
Top of contents


投稿された内容の著作権はコメントの投稿者に帰属します。
投稿者 スレッド