Redmine_test_install

Redmineを使ってみようと思ってテスト環境と作ってみる。
とりあえず、VMに環境を作ってみる。
テスト環境だし折角なので、FreeBSD9.1RC1 amd64を使ってみる事にする。

#amd64を使いましょうとのことなので

材料


2012-08-31 midnight

インストール途中のつぶやき(Twitterで呟いているわけではない. そのうち消す)

ガントチャートを書きたいので、ImageMagickをインストールしたいだけなのだけど、RMagickでもいいんだろうか?

ApacheとRuby on Railsを連携させるのにPassengerってのが必要なのか?

とりあえず、ports/ImageMagickのmakeは終わったっぽい。

うーん、make installは止めとくかなぁ。


2012-09-01


2012-09-03

Apache2.2.22 Install

mysql5.5

ImageMagick

Mercurial

# cd /usr/ports/devel/mercurial
# make; make install

Ruby

# cd /usr/ports/lang/ruby18
# make; make install

gem

# cd /usr/ports/devel/ruby-gems
# make; make install

gem自身でgemのアップデートをする

# gem update --system
Latest version currently installed. Aborting.

ということで,アップデートの必要はないらしい。

rails

# gem install rails

Enterキーを叩いてもしばらく,何も反応しないのであるが,ここは待つことにする。 するとしばらくしてインストールがはじまるのだが...

ERROR:  While executing gem ... (Gem::DocumentError)
    ERROR: RDoc documentation generator not installed: no such file to load -- iconv

となりまする。

/usr/portsの中でiconvを調べると

converters/iconv
converters/ruby-iconv
:

といろいろ出てくる。 ここは,converter/ruby-iconvを入れてみる。

# cd /usr/ports/converters/ruby-iconv
# make; make install

あっという間に終わる。

再度,

# gem install rails

ん?

# gem install rails
Successfully installed rails-3.2.8
1 gem installed
Installing ri documentation for rails-3.2.8...
Installing RDoc documentation for rails-3.2.8...
#

あっさり終わった。いいのか。いいんだ。

MySQLのC bindingをインストール

# gem install mysql2

bundlerをインストール

# gem install bundler

さて,ここまでが,redmineをインストールするための種 ここから先は,redmineにインストール手順に従ってっやてみましょ。

Redmine

redmienのソースをサイトからgetする。

これを展開してインストールしていくんだけど,展開した先でredmineが動作する(?)ようなので,/usr/local/redmineに配置する。

% tar xvzf redmine-2.0.3
# mv redmine-2.0.3 /usr/local/redmine
# cd /usr/local/redmine

がしかし,

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql- 2.8.1/ext/mysql_api/gem_make.out
An error occurred while installing mysql (2.8.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.8.1'` succeeds before bundling.

とエラーが出る。

うーむ,mysqlは先に入れているので,先にmysqlにユーザを作る。

create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost';

config/database.example.yml をコピーして config/database.yml を作成する。

# cp config/database.yml.example config/database.yml
# vi database.yml
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: my_password
  encoding: utf8

再びbundle

# bundle install --without development test postgresql sqlite
 :
Installing mysql (2.8.1) with native extensions
 :

先ほどエラーとなったmysqlのインストールは,native extensionsとなっており,インストールできた模様。さらに

Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

としてbundleも完了した模様。

 Tasks: TOP => db:migrate => environment
 (See full trace by running task with --trace)

うーん,失敗する。

Redmine.jpのインストールでmysqlに失敗する場合,rails wiki pagesを参照せよとあるので,そちらをみて,

# gem install mysql – –with-mysql-config=/usr/bin/mysql_config

を実行してみた。

# gem install mysql - -with-mysql-config=/usr/local/mysql/bin/mysql_config
Fetching: mysql-2.8.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...
# setenv LD_LIBRARY_PATH /usr/local/mysql/lib
# ldconfig
# gem install mysql -- --with-mysql-lib=/usr/local/mysql/lib --with-mysql-config=/usr/local/mysql/bin/mysql_config
# rake db:migrate

このページを参考にした>http://www.binrand.com/post/1080301-gems-ruby-undefined-method-init-for-mysql-class.html

デフォルトデータをデータベースに登録する

# rake redmine:load_default_data

Redminを実行するユーザーは次のディレクトリに対して書き込み権限が必要

files, log, tmp (tmpが無ければ作成する)

# mkdir tmp public/plugin_assets 
# chown -R redmine:redmine files log tmp public/plugin_assets
# chmod -R 755 files log tmp public/plugin_assets

WEBrickによるwebサーバを起動して、インストールができたかテストする。

# ruby script/rails server webrick -e production

WEBrickが起動したら、ブラウザで http://localhost:3000/にアクセスする

デフォルトでは,ユーザ名,パスワードともadmin

Apacheとpassengerを連携させる

setenv APXS2 /usr/local/sbin/apxs
setenv APR_CONFIG /usr/local/lib/apache2/apr-config
setenv APU_CONFIG /usr/local/lib/apache2/apu-config

2012-09-04

rake db:migrateとpassengerでエラー

結局,このエラーは,passengerにてApacheとrailsを連携したときもでている。

undefined method `init' for Mysql:Class

切り分けるために素の状態からインストールしていく。最初にインストールしたときは,ruby1.9系だった。2回目は,ruby1.8系だった。rubyが1.8系の時はマイグレーションの時LD_LIBRARY_PATHを設定するとうまくいくが,結局passengerでapacheと連携するとうまくいかいない。

なので,rubyを1.9系にしてpassengerでApacheとRailsの連携まで行ってみる。

% ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [amd64-freebsd9]

gemのインストール

# cd /usr/ports/devel/ruby-gems
# make install clean
# gem upate --system
Latest version currently installed. Aborting.
#

ちゃんとインストールできたっぽい。

このあと,railsのインストールに進むのである。gem install railsでインストールされるrailsのバージョンは,3.2.8。

ところが,redmineのbundlerでインストールされるrailsは3.2.6。

この差が気になるので,今回は,railsのインストールはredmineのbundlerに任せることにしてデータベースを設定しましょ。

データベースを起動して,ユーザを作る

まえのまま。

さて,redmineをインストール

  1. cd /usr/local/
  2. tar xvzf redmine-2.0.3.tar.gz
  3. mf redmine-2.0.3 redmine
  4. cd redmine/config
  5. cp database.yml.example database.yml
  6. vi database.yml productionの項目を合わせる
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: password
  1. gem install bundler --no-rdoc --no-ri bundlerがインストールできたので,
    # cd /usr/local/redmine
    # bundle install --without development test postgresql sqlite
    がしかし,mysqlのところでエラー発生。
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native  extension.
        /usr/local/bin/ruby18 extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options. 

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/bin/ruby18
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mlib
        --without-mlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-zlib
        --without-zlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-socketlib
        --without-socketlib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-nsllib
        --without-nsllib
        --with-mysqlclientlib
        --without-mysqlclientlib
        --with-mygcclib
        --without-mygcclib
        --with-mysqlclientlib
        --without-mysqlclientlib
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql- 2.8.1/ext/mysql_api/gem_make.out
An error occurred while installing mysql (2.8.1), and Bundler cannot continue.
Make sure that `gem install mysql -v '2.8.1'` succeeds before bundling.

redmine.jpに1.0系でインストールするときはmysql2を使えと書いてあったので,

# gem install mysql2

を行ったあと,mysqlも除いてbundlerでインストールしてみる。

# bundle install --without development test postgresql sqlite mysql

無事に終わった模様

セッションストア鍵を作ります。

# rake generate_secret_token
rake aborted!
no such file to load -- iconv

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

おや,iconvでエラーですか。ならば,

# gem install iconv
Fetching: iconv-0.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing iconv:
        ERROR: Failed to build gem native extension. 

        /usr/local/bin/ruby18 extconf.rb
checking for iconv() in iconv.h... no
checking for iconv() in -liconv... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

そうですか,portsのconverterからruby-iconvをインストールする。

# cd /usr/ports/converters/ruby-iconv
# make install clean
# rake generate_secret_token
#

成功!

さて,次が問題のマイグレーション

# rake db:migrate RAILS_ENV=production

rake aborted!
Please install the mysql adapter: `gem install activerecord-mysql-adapter`  (mysql is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

ん?いままでとはちょっと違うメッセージ
メッセージの通りしてみましょ。

# gem install activerecord-mysql-adapter

gem i activerecord-mysql-adapter
ERROR:  Could not find a valid gem 'activerecord-mysql-adapter' (>= 0) 
in any repository

activerecord-mysql-adapterの意味が違ったか。うーむ。

とりえあず,mysql2をuninstallしてmysqlをインストールしてみる。 今度は,mysql-dirを指定してみる。

# gem install mysql -- --with-mysql-dir=/usr/local/mysql
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...

素直に入った。

さて...

# gem install mysql -- --with-mysql-dir=/usr/local/mysql \
                       --with-mysql-include=/usr/local/mysql/include \
                       --with-mysql-lib=/usr/local/mysql/lib

なんか,Provided configuration options:にmysql関連のオプションがあったので,こんふぃぐ以外を全部つけてみた。

# rake db:migrate RAILS_ENV=production
   :
   :

成功!

# rake redmine:load_default_data REILS_ENV=production

webricで確認してきた。ふぅ。

Passengerで連携 #なんかできそうな気がしてきた。

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

passengerがインストールできたのでコマンドですね。

# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.17.

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... not 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... not found
 * Apache 2 development headers... not found
 * Apache Portable Runtime (APR) development headers... not found
 * Apache Portable Runtime Utility (APU) development headers... not found

 Some required software is not installed.
 But don't worry, this installer will tell you how to install them.

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

見つからないといっているのは,curlとapache関連

まずは,curl

# cd /usr/ports/ftp/curl
# make install clean;

次にapache関連

setenv APXS2 /usr/local/apache2/bin/apxs
setenv APR_CONFIG /usr/local/apache2/bin/apr-1-config
setenv APU_CONFIG /usr/local/apache2/bin/apu-1-config

再度,passenger-install-apache2-moduleを実行すると今度は,必要な素材が見つかってapache用のモジュールが生成された。

で,これをapacheに設定するばよいのね。

 LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
 PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.17
 PassengerRuby /usr/local/bin/ruby18

サブディレクトリをredmineにする

シンボリックリンクを使って,redmineをapache配下に

# ln -s /usr/local/redmine/public /usr/local/apache/htdocs/redmine

Apacheへの設定追加

RailsBaseURI /redmine

2012-09-06

VMマシン上でテストしていたんだけど,本機のテスト環境でインストールしようとしたらやっぱり,「undefined method `init' for Mysql:Class」に悩まされる。

この前dbはmysql一本で行こうってことにしたけど,ここは,SQLite3を使ってみたら,あっさり稼働した。

本番機は,SQLiteかな。

RoRとMySQLの連携で悩むよりRedmineを使っていきたいし。 http://htrmine.blog52.fc2.com/category3-1.html


2012-09-08

本機の環境は,FreeBSD71 #今度アップしよう + MySQL5.1
ここでは,undefined method `init' for Mysql:Classに悩まされた。mysql2を使えば解決するとかruby-mysqlを使えば大丈夫だとか。

config/database.ymlのadapterをmysqlからmysql2に変えたりしたけど効果なしだった。 これは,どうもruby1.8が使われていたためにmysql2を使用していなかったらしい。

いろいろなページを眺めていて, FreeBSD 9.0 + Redmine + Ruby19

# Install required dependancies
echo "RUBY_VERSION=1.9.3" >> /etc/make.conf

によりrubyのバージョンを固定すれば...と さっそく,make.confに記述し,ruby, gem, bundlerを再インストールした。

bundlerによりredmine関連のモジュールをインストールするときにmysqlの項目がmysql2に代わっていた。

その後,rake db:migrateを行うと問題なく終了!

これで,mysqlを使うことができる。

#mysqlを必ず使わなくてはならないわけぢゃないんだけど,

#できないと気になるじゃん。

評価で使ってもらおうと思ったらどかーんと使ってしまっているユーザもいるので,sqliteからmysqlへデータの移行をしなくちゃ。

最初から飛ばすぜっって感じでいろいろ体験できちゃう。


2012-09-10

まだまだ続いていたりする。

ruby1.9系のテストをしていたら,ruby1.8系でテストドライブしていたRedmineを止めてしまったので,ruby1.8系に戻した。

そうしたらruby1.8系と1.9系が混在していた環境となってしまい,エラーが出ていなかったところでもエラーが報告されるようになってしまった。

なので,rubyを含め,Redmine関連でインストールしたものを全て削除した。

改めてruby1.9系で,Redmine環境を作ってwebrickで動作していることを確認したので, passengerを入れてApacheと連携させようとしたら...奥さんっ!

NotImplementedError: fork() function is unimplemented on this machine

forkのエラーが出る orz...

thread forkとprocess forkの違いという記述もどこかで見つけた。そうするとApacheのコンフィグレーションも関連しているかもしれないなと。

ということで,現状では,ruby1.8系でRedmineをドライブすることにする。


Last-modified: 2022-05-05 (木) 22:27:10