スポンサーサイト
上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。
新しい記事を書く事で広告が消せます。
DBD-Pgをインストール
RHEL ES4 Update3 x86_64での話。
DBI + DBD-PgでPostgresに接続したくなった。
DBIは既にインストール済みだったからDBD-Pgをインストール
↓
# gem install dbd-pg
でもエラー
↓
Postgres関連のパッケージが足りないっぽい。
とりあえず現状何がインストールされているか確認
↓
# rpm -qa | grep postgres
postgresql-libs-7.4.8-1.RHEL4.1
古い。まずはこれをアップデート(RPMはRHNからダウンロード)
↓
# rpm -Uvh postgresql-libs-7.4.30-1.el4_8.2.x86_64.rpm
あと必要と思われるRPMをインストール(同じくRPMはRHNからダウンロード)
↓
# rpm -ivh postgresql-7.4.30-1.el4_8.2.x86_64.rpm postgresql-devel-7.4.30-1.el4_8.2.x86_64.rpm
DBD-Pgのインストール再チャレンジ
↓
# gem install dbd-pg
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
Successfully installed dbd-pg-0.3.9
2 gems installed
Installing ri documentation for dbd-pg-0.3.9...
Installing RDoc documentation for dbd-pg-0.3.9...
うまくいった。
DBI + DBD-PgでPostgresに接続したくなった。
DBIは既にインストール済みだったからDBD-Pgをインストール
↓
# gem install dbd-pg
でもエラー
↓
Building native extensions. This could take a while...
ERROR: Error installing dbd-pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb install dbd-pg
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/pg-0.11.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.11.0/ext/gem_make.out
Postgres関連のパッケージが足りないっぽい。
とりあえず現状何がインストールされているか確認
↓
# rpm -qa | grep postgres
postgresql-libs-7.4.8-1.RHEL4.1
古い。まずはこれをアップデート(RPMはRHNからダウンロード)
↓
# rpm -Uvh postgresql-libs-7.4.30-1.el4_8.2.x86_64.rpm
あと必要と思われるRPMをインストール(同じくRPMはRHNからダウンロード)
↓
# rpm -ivh postgresql-7.4.30-1.el4_8.2.x86_64.rpm postgresql-devel-7.4.30-1.el4_8.2.x86_64.rpm
DBD-Pgのインストール再チャレンジ
↓
# gem install dbd-pg
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
Successfully installed dbd-pg-0.3.9
2 gems installed
Installing ri documentation for dbd-pg-0.3.9...
Installing RDoc documentation for dbd-pg-0.3.9...
うまくいった。
スポンサーサイト
rvm + ruby + Passengerのインストール
OSはFedora 14 x86_64。
rvmをインストール
↓
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
~/.bashrcに↓を追加
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
ruby 1.9.2の最新をインストール
↓
$ rvm install 1.9.2-head
rubyを今入れた1.9.2-headにする
↓
$ rvm use 1.9.2-head
デフォルトのrubyを今入れた1.9.2-headにする
↓
$ rvm use 1.9.2-head --default
こんな感じになる
↓
$ ruby -v
ruby 1.9.2p160 (2011-01-16 revision 30579) [x86_64-linux]
$ which ruby
~/.rvm/rubies/ruby-1.9.2-head/bin/ruby
次にPassengerをインストールする。
Passengerで使うrubyを選択
↓
$ rvm 1.9.2-head --passenger
Passengerで使うrubyに切り替え(デフォルトを1.9.2-headにしたから多分必要ないけど一応)
↓
$ rvm 1.9.2-head
gemをインストール
↓
$ gem install passenger
apache用モジュールをインストール
↓
$ rvmsudo passenger-install-apache2-module
エラー…。とりあえず言うとおりに
↓
$ rvm update --head
$ rvm reload
$ rvm repair all
で、再度apache用モジュールをインストール
↓
$ rvmsudo passenger-install-apache2-module
同じエラーが出る。環境変数確認
↓
$ rvmsudo bash -c export
ruby_pathが無い…。ということでこんな感じでインストール
↓
$ rvmsudo 'rvm_path=/home/hoge-user/.rvm;passenger-install-apache2-module'
httpd-devel、apr-devel、apr-util-develが無いよとのこと。
httpd-develは入ってないけど、apr-develとapr-util-develは入ってるのだが…。
とりあえずhttpd-develをインストール
↓
$ su-
# yum install httpd-devel
で、再々度apache用モジュールをインストール
↓
# exit
$ rvmsudo 'rvm_path=/home/hoge-user/.rvm;passenger-install-apache2-module'
httpd-devel入れたらほかの2つもfoundになって無事インストール完了。
最後の方でapacheの設定に関する指示が出力される
↓
rvmをインストール
↓
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
~/.bashrcに↓を追加
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
ruby 1.9.2の最新をインストール
↓
$ rvm install 1.9.2-head
rubyを今入れた1.9.2-headにする
↓
$ rvm use 1.9.2-head
デフォルトのrubyを今入れた1.9.2-headにする
↓
$ rvm use 1.9.2-head --default
こんな感じになる
↓
$ ruby -v
ruby 1.9.2p160 (2011-01-16 revision 30579) [x86_64-linux]
$ which ruby
~/.rvm/rubies/ruby-1.9.2-head/bin/ruby
次にPassengerをインストールする。
Passengerで使うrubyを選択
↓
$ rvm 1.9.2-head --passenger
Passengerで使うrubyに切り替え(デフォルトを1.9.2-headにしたから多分必要ないけど一応)
↓
$ rvm 1.9.2-head
gemをインストール
↓
$ gem install passenger
apache用モジュールをインストール
↓
$ rvmsudo passenger-install-apache2-module
[sudo] password for hoge-user:
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.2.
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/lib64/ccache/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
Unable to locate the RVM path. Your RVM installation is probably too old. Please update it with 'rvm update --head && rvm reload && rvm repair all'.
エラー…。とりあえず言うとおりに
↓
$ rvm update --head
'rvm update --head' is deprecated, use 'rvm get head' instead
Original installed RVM version:
rvm 1.2.4 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
remote: Counting objects: 86, done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 65 (delta 42), reused 4 (delta 1)
Unpacking objects: 100% (65/65), done.
From git://github.com/wayneeseguin/rvm
* branch master -> FETCH_HEAD
Updating cac5428..7e622b3
Fast-forward
LICENCE | 24 ++++++--------
README | 7 ++++
config/db | 3 +-
config/md5 | 1 +
contrib/bootstrap_rails_environment | 2 +-
contrib/install-system-wide | 9 ++++-
lib/VERSION.yml | 2 +-
pkg/gentoo/rvm-1.2.5.ebuild | 59 +++++++++++++++++++++++++++++++++++
scripts/cli | 4 +-
scripts/help | 3 +-
scripts/maglev | 22 ++++++-------
scripts/manage | 5 ++-
scripts/notes | 8 ++--
scripts/rubygems | 2 +-
scripts/utility | 2 +-
15 files changed, 111 insertions(+), 42 deletions(-)
create mode 100644 pkg/gentoo/rvm-1.2.5.ebuild
RVM: Shell scripts enabling management of multiple ruby environments.
RTFM: http://rvm.beginrescueend.com/
HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
Upgrading the RVM installation in /home/hoge-user/.rvm/
Correct permissions for base binaries in /home/hoge-user/.rvm/bin...
Copying manpages into place.
Upgrade Notes
* rvm_trust_rvmrcs has been changed to rvm_trust_rvmrcs_flag for consistency
* Ruby package dependency list for your OS is given by:
rvm notes
* If you encounter any issues with a ruby 'X' your best bet is to:
rvm remove X ; rvm install X
* If you wish to have the 'pretty colors' again, set in ~/.rvmrc:
export rvm_pretty_print_flag=1
* If you see the following error message: Unknown alias name: 'default'
re-set your default ruby, this is due to a change in how default works.
Upgrade of RVM in /home/hoge-user/.rvm/ is complete.
hoge-user,
Thank you very much for using RVM! I sincerely hope that RVM helps to
make your work both easier and more enjoyable.
If you have any questions, issues and/or ideas for improvement please
join#rvm on irc.freenode.net and let me know, note you must register
(http://bit.ly/5mGjlm) and identify (/msg nickserv <nick> <pass>) to
talk, this prevents spambots from ruining our day.
My irc nickname is 'wayneeseguin' and I hang out in #rvm typically
~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT
If I do not respond right away, please hang around after asking your
question, I will respond as soon as I am back. It is best to talk in
#rvm itself as then other users can help out should I be offline.
Be sure to get head often as rvm development happens fast,
you can do this by running 'rvm get head' followed by 'rvm reload'
or opening a new shell
w???t
~ Wayne
Installed RVM HEAD version:
rvm 1.2.5 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
$ rvm reload
$ rvm repair all
Repairing symlinks...
Symlinks repaired
Repairing archives...
Archives repaired
Regenerating environments...
Regenerating environment file for 'ruby-1.9.2-head'
Regenerating environment file for 'ruby-1.9.2-head@global'
Environments regenerated
Regenerating all wrappers...
Regenerating wrappers for ruby-1.9.2-head
Regenerating wrappers for ruby-1.9.2-head@global
Wrappers regenerated
で、再度apache用モジュールをインストール
↓
$ rvmsudo passenger-install-apache2-module
同じエラーが出る。環境変数確認
↓
$ rvmsudo bash -c export
ruby_pathが無い…。ということでこんな感じでインストール
↓
$ rvmsudo 'rvm_path=/home/hoge-user/.rvm;passenger-install-apache2-module'
[sudo] password for hoge-user:
HOSTNAME=hoge-host-fedora
TERM=vt100
HISTSIZE=1000
QTDIR=/usr/lib64/qt-3.3
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL=/var/spool/mail/hoge-user
LANG=ja_JP.UTF-8
SHELL=/bin/bash
LOGNAME=root
USER=root
USERNAME=root
PATH=/home/hoge-user/.rvm/gems/ruby-1.9.2-head/bin:/home/hoge-user/.rvm/gems/ruby-1.9.2-head@global/bin:/home/hoge-user/.rvm/rubies/ruby-1.9.2-head/bin:/home/hoge-user/.rvm/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hoge-user/bin
HOME=/root
SUDO_COMMAND=/usr/bin/env GEM_PATH=/home/hoge-user/.rvm/gems/ruby-1.9.2-head:/home/hoge-user/.rvm/gems/ruby-1.9.2-head@global GEM_HOME=/home/hoge-user/.rvm/gems/ruby-1.9.2-head PATH=/home/hoge-user/.rvm/gems/ruby-1.9.2-head/bin:/home/hoge-user/.rvm/gems/ruby-1.9.2-head@global/bin:/home/hoge-user/.rvm/rubies/ruby-1.9.2-head/bin:/home/hoge-user/.rvm/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hoge-user/bin rvm_path=/home/hoge-user/.rvm
SUDO_USER=hoge-user
SUDO_UID=500
SUDO_GID=500
GEM_PATH=/home/hoge-user/.rvm/gems/ruby-1.9.2-head:/home/hoge-user/.rvm/gems/ruby-1.9.2-head@global
GEM_HOME=/home/hoge-user/.rvm/gems/ruby-1.9.2-head
rvm_path=/home/hoge-user/.rvm
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.2.
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/lib64/ccache/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 /home/hoge-user/.rvm/wrappers/ruby-1.9.2-head/rake
* rack... found
* Apache 2... found at /usr/sbin/httpd
* 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.
--------------------------------------------
Installation instructions for required software
* To install Apache 2 development headers:
Please run yum install httpd-devel as root.
* To install Apache Portable Runtime (APR) development headers:
Please run yum install apr-devel as root.
* To install Apache Portable Runtime Utility (APU) development headers:
Please run yum install apr-util-devel as root.
If the aforementioned instructions didn't solve your problem, then please take
a look at the Users Guide:
/home/hoge-user/.rvm/gems/ruby-1.9.2-head/gems/passenger-3.0.2/doc/Users guide Apache.html
httpd-devel、apr-devel、apr-util-develが無いよとのこと。
httpd-develは入ってないけど、apr-develとapr-util-develは入ってるのだが…。
とりあえずhttpd-develをインストール
↓
$ su-
# yum install httpd-devel
で、再々度apache用モジュールをインストール
↓
# exit
$ rvmsudo 'rvm_path=/home/hoge-user/.rvm;passenger-install-apache2-module'
httpd-devel入れたらほかの2つもfoundになって無事インストール完了。
最後の方でapacheの設定に関する指示が出力される
↓
--------------------------------------------
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /home/hoge-user/.rvm/gems/ruby-1.9.2-head/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
PassengerRoot /home/hoge-user/.rvm/gems/ruby-1.9.2-head/gems/passenger-3.0.2
PassengerRuby /home/hoge-user/.rvm/wrappers/ruby-1.9.2-head/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:
/home/hoge-user/.rvm/gems/ruby-1.9.2-head/gems/passenger-3.0.2/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.
ruby1.8.6から1.8.7にバージョンアップ
ruby1.8.6-p111から1.8.7-p302にバージョンアップした(rubygemsも1.3.1から1.3.7へ)。都合により、1.8.6-p111環境は一度全部削除した。OSはRHEL ES4 Update4 x86_64。
【ruby1.8.6-p111とrubygems1.3.1を削除】
ruby1.8.6-p111はcheckinstallでRPM化してインストールしていた…はずだったが、インストールのとき色々試しながら作業していてmake installとcheckinstallを繰り返していたせいか、RPMに必要なファイル一式がそろっていなかった。
ということで、まず手動でrubyほか関連ファイルを手動削除してからRPMを削除。
# rm /usr/bin/erb
# rm /usr/bin/irb
# rm /usr/bin/rdoc
# rm /usr/bin/ri
# rm /usr/bin/ruby
# rm /usr/bin/testrb
# rm /usr/bin/sqlsh.rb
# rm /usr/lib/libruby-static.a
# rm -rf /usr/lib/ruby/
# rm -rf /usr/doc/ruby-1.8.6
# rm -rf /usr/doc/rubygems
# rpm -qa | grep ruby
ruby-1.8.6-p111-1
rubygems-1.3.1-1
# rpm -e ruby-1.8.6-p111-1
# rpm -e rubygems-1.3.1-1
【ruby 1.8.7-p302とrubygems 1.3.7をビルド&RPM化してインストール】
ソースを/usr/local/srcにダウンロードしておく。
# cd /usr/local/src
# tar zxf ruby-1.8.7-p302.tar.gz
# cd ruby-1.8.7-p302
# ./configure --prefix=/usr
# make
# checkinstall --inspect --fstrans=no
# cd /usr/local/src
# tar zxf rubygems-1.3.7.tar.gz
# cd rubygems-1.3.7
# checkinstall --inspect -R "ruby setup.rb"
vi編集画面で/usr/bin/rubyを削除
# cd /usr/src/redhat/RPMS/x86_64
# rpm -ivh ruby-1.8.7-1.x86_64.rpm
# rpm -ivh rubygems-1.3.7-1.x86_64.rpm
【gemでライブラリーをインストール】
インストールするのは、rails、fastercsv、ruby-oci8、dbi、activerecord-oracle_enhanced-adapter。
基本的に
# gem install ライブラリ名
でいいけど、ruby-oci8はインストール前に
# export ORACLE_BASE=/opt/app/oracle
# export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client
# export LD_LIBRARY_PATH=$ORACLE_HOME/lib
# export NLS_LANG=JAPANESE_JAPAN.JA16EUC
# export PATH=$PATH:$ORACLE_HOME/bin
# export TNS_ADMIN=$ORACLE_HOME/network/admin
みたいにOracleの環境変数設定が必要。
【補足1】
1.8.6のときはOracleの環境変数TNS_ADMINが無くても動いたんだけど、今回アップデートしたら無いとダメになった。理由は分からない。絡みそうな今回の変更点は、
・ruby本体、各ライブラリのバージョンアップ
・ruby-oci8とdbiはソースをmake installからgemによるインストールに変えた
【補足2】
ruby-oci8とdbiをソースからmake installした場合は、
【ruby-oci8インストール先】
/usr/lib/ruby/site_ruby/1.8/x86_64-linux/oci8lib.so
/usr/lib/ruby/site_ruby/1.8/oci8.rb
/usr/lib/ruby/site_ruby/1.8/DBD/OCI8
/usr/lib/ruby/site_ruby/1.8/DBD/OCI8/OCI8.rb
【dbiインストール先】
/usr/lib/ruby/site_ruby/1.8/dbi
/usr/lib/ruby/site_ruby/1.8/dbi.rb
/usr/bin/sqlsh.rb
とかにインストールされているはずだから、ruby-oci8、dbiだけをgemに変える場合はまずこれらを削除すれば良い。
【その他】
thinを使う場合はこういうのにも注意。
【ruby1.8.6-p111とrubygems1.3.1を削除】
ruby1.8.6-p111はcheckinstallでRPM化してインストールしていた…はずだったが、インストールのとき色々試しながら作業していてmake installとcheckinstallを繰り返していたせいか、RPMに必要なファイル一式がそろっていなかった。
ということで、まず手動でrubyほか関連ファイルを手動削除してからRPMを削除。
# rm /usr/bin/erb
# rm /usr/bin/irb
# rm /usr/bin/rdoc
# rm /usr/bin/ri
# rm /usr/bin/ruby
# rm /usr/bin/testrb
# rm /usr/bin/sqlsh.rb
# rm /usr/lib/libruby-static.a
# rm -rf /usr/lib/ruby/
# rm -rf /usr/doc/ruby-1.8.6
# rm -rf /usr/doc/rubygems
# rpm -qa | grep ruby
ruby-1.8.6-p111-1
rubygems-1.3.1-1
# rpm -e ruby-1.8.6-p111-1
# rpm -e rubygems-1.3.1-1
【ruby 1.8.7-p302とrubygems 1.3.7をビルド&RPM化してインストール】
ソースを/usr/local/srcにダウンロードしておく。
# cd /usr/local/src
# tar zxf ruby-1.8.7-p302.tar.gz
# cd ruby-1.8.7-p302
# ./configure --prefix=/usr
# make
# checkinstall --inspect --fstrans=no
# cd /usr/local/src
# tar zxf rubygems-1.3.7.tar.gz
# cd rubygems-1.3.7
# checkinstall --inspect -R "ruby setup.rb"
vi編集画面で/usr/bin/rubyを削除
# cd /usr/src/redhat/RPMS/x86_64
# rpm -ivh ruby-1.8.7-1.x86_64.rpm
# rpm -ivh rubygems-1.3.7-1.x86_64.rpm
【gemでライブラリーをインストール】
インストールするのは、rails、fastercsv、ruby-oci8、dbi、activerecord-oracle_enhanced-adapter。
基本的に
# gem install ライブラリ名
でいいけど、ruby-oci8はインストール前に
# export ORACLE_BASE=/opt/app/oracle
# export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client
# export LD_LIBRARY_PATH=$ORACLE_HOME/lib
# export NLS_LANG=JAPANESE_JAPAN.JA16EUC
# export PATH=$PATH:$ORACLE_HOME/bin
# export TNS_ADMIN=$ORACLE_HOME/network/admin
みたいにOracleの環境変数設定が必要。
【補足1】
1.8.6のときはOracleの環境変数TNS_ADMINが無くても動いたんだけど、今回アップデートしたら無いとダメになった。理由は分からない。絡みそうな今回の変更点は、
・ruby本体、各ライブラリのバージョンアップ
・ruby-oci8とdbiはソースをmake installからgemによるインストールに変えた
【補足2】
ruby-oci8とdbiをソースからmake installした場合は、
【ruby-oci8インストール先】
/usr/lib/ruby/site_ruby/1.8/x86_64-linux/oci8lib.so
/usr/lib/ruby/site_ruby/1.8/oci8.rb
/usr/lib/ruby/site_ruby/1.8/DBD/OCI8
/usr/lib/ruby/site_ruby/1.8/DBD/OCI8/OCI8.rb
【dbiインストール先】
/usr/lib/ruby/site_ruby/1.8/dbi
/usr/lib/ruby/site_ruby/1.8/dbi.rb
/usr/bin/sqlsh.rb
とかにインストールされているはずだから、ruby-oci8、dbiだけをgemに変える場合はまずこれらを削除すれば良い。
【その他】
thinを使う場合はこういうのにも注意。
rubyがprelinkで壊れた
rubyをインストールしてプログラムを書いた。普通に動いてたのに翌日になったら動かない。
OSはRHEL5.2、rubyは1.9.2。
rubyを再インストールしたら元通り動いたから、何が原因だったのだろうと思いつつそのまま放置。
で、数日後同じプログラムを動かしたらまたエラーで動かない。
ていうか
# gem list
が、正常に動作しなくて
<internal:lib/rubygems/custom_require>:29:in `require'
・・・
とかエラーが出たり、時にはSegmentation faultになったりする。
かと思うとたまに正常に動作したりもする。
どうやらprelinkがゴリゴリとrubyを壊して(?)いたらしい。
# prelink -au
をしたら(gem listも作成したプログラムも)元通り正常に実行できるようになった。
rubyのファイルサイズ比較
↓
■prelinkでダメになったruby
# ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 5712719 10月 30 14:47 /usr/bin/ruby
■prelink -auして実行できるようになったruby
# ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 5706575 10月 30 14:47 /usr/bin/ruby
■その後、気持ち悪いから改めてビルドし直して再インストールしたruby
# ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 1943280 11月 2 21:22 /usr/bin/ruby
prelinkは削除した。
OSはRHEL5.2、rubyは1.9.2。
rubyを再インストールしたら元通り動いたから、何が原因だったのだろうと思いつつそのまま放置。
で、数日後同じプログラムを動かしたらまたエラーで動かない。
ていうか
# gem list
が、正常に動作しなくて
<internal:lib/rubygems/custom_require>:29:in `require'
・・・
とかエラーが出たり、時にはSegmentation faultになったりする。
かと思うとたまに正常に動作したりもする。
どうやらprelinkがゴリゴリとrubyを壊して(?)いたらしい。
# prelink -au
をしたら(gem listも作成したプログラムも)元通り正常に実行できるようになった。
rubyのファイルサイズ比較
↓
■prelinkでダメになったruby
# ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 5712719 10月 30 14:47 /usr/bin/ruby
■prelink -auして実行できるようになったruby
# ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 5706575 10月 30 14:47 /usr/bin/ruby
■その後、気持ち悪いから改めてビルドし直して再インストールしたruby
# ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 1943280 11月 2 21:22 /usr/bin/ruby
prelinkは削除した。
ruby 1.9.2をRPM化してインストール
公式サイトからソースをダウンロード。
で、ビルド
↓
# tar zxf ruby-1.9.2-p0.tar.gz
# cd ruby-1.9.2-p0
# ./configure --prefix=/usr
# make
# checkinstall --inspect --fstrans=no
checkinstallの手順はこれとだいたい同じなんだけど、1点、
You probably don't want them to be included in the package,
especially if they are inside your home directory.
Do you want me to list them? [n]:ENTER
それらをパッケージから除外しますか?(yesと答えることをおすすめします) [y]: n ← ここをnoにする
にしないと、
tempディレクトリにファイルをコピー..
のところで固まってエラーになる。
で、--inspectオプションを指定してるからパッケージするリストをviで編集する画面に入るわけなんだけど、
DIR/ruby-1.9.2-p0/・・・
・・・
DIR/ruby-1.9.2-p0/ext/dl
DIR/ruby-1.9.2-p0/ext/dl/callback
DIR/ruby-1.9.2-p0/ext/dl/win32
DIR/ruby-1.9.2-p0/ext/etc
DIR/ruby-1.9.2-p0/ext/fcntl
DIR/ruby-1.9.2-p0/ext/fiber
DIR/ruby-1.9.2-p0/ext/fiddle
DIR/ruby-1.9.2-p0/ext/gdbm
DIR/ruby-1.9.2-p0/ext/iconv
DIR/ruby-1.9.2-p0/ext/io/nonblock
DIR/ruby-1.9.2-p0/ext/io/wait
DIR/ruby-1.9.2-p0/ext/json
DIR/ruby-1.9.2-p0/ext/json/generator
・・・
DIR/ruby-1.9.2-p0/・・・
の部分は要らないから削除しておく。DIRの部分はrubyのソースをダウンロードしたディレクトリ。
ということで、できたRPMをインストール(RPMは/usr/src/redhat/RPMS/i386/とか/root/rpmbuild/RPMS/i386/にあるはず)
↓
# cd /usr/src/redhat/RPMS/i386/
# rpm -ivh ruby-1.9.2-1.i386.rpm
そしてエラー
↓
エラー: 依存性の欠如:
/usr/bin/ruby は ruby-1.9.2-1.i386 に必要とされています
オプションをつけてやり直し
↓
# rpm -ivh --nodeps ruby-1.9.2-1.i386.rpm
で、ビルド
↓
# tar zxf ruby-1.9.2-p0.tar.gz
# cd ruby-1.9.2-p0
# ./configure --prefix=/usr
# make
# checkinstall --inspect --fstrans=no
checkinstallの手順はこれとだいたい同じなんだけど、1点、
You probably don't want them to be included in the package,
especially if they are inside your home directory.
Do you want me to list them? [n]:ENTER
それらをパッケージから除外しますか?(yesと答えることをおすすめします) [y]: n ← ここをnoにする
にしないと、
tempディレクトリにファイルをコピー..
のところで固まってエラーになる。
で、--inspectオプションを指定してるからパッケージするリストをviで編集する画面に入るわけなんだけど、
DIR/ruby-1.9.2-p0/・・・
・・・
DIR/ruby-1.9.2-p0/ext/dl
DIR/ruby-1.9.2-p0/ext/dl/callback
DIR/ruby-1.9.2-p0/ext/dl/win32
DIR/ruby-1.9.2-p0/ext/etc
DIR/ruby-1.9.2-p0/ext/fcntl
DIR/ruby-1.9.2-p0/ext/fiber
DIR/ruby-1.9.2-p0/ext/fiddle
DIR/ruby-1.9.2-p0/ext/gdbm
DIR/ruby-1.9.2-p0/ext/iconv
DIR/ruby-1.9.2-p0/ext/io/nonblock
DIR/ruby-1.9.2-p0/ext/io/wait
DIR/ruby-1.9.2-p0/ext/json
DIR/ruby-1.9.2-p0/ext/json/generator
・・・
DIR/ruby-1.9.2-p0/・・・
の部分は要らないから削除しておく。DIRの部分はrubyのソースをダウンロードしたディレクトリ。
ということで、できたRPMをインストール(RPMは/usr/src/redhat/RPMS/i386/とか/root/rpmbuild/RPMS/i386/にあるはず)
↓
# cd /usr/src/redhat/RPMS/i386/
# rpm -ivh ruby-1.9.2-1.i386.rpm
そしてエラー
↓
エラー: 依存性の欠如:
/usr/bin/ruby は ruby-1.9.2-1.i386 に必要とされています
オプションをつけてやり直し
↓
# rpm -ivh --nodeps ruby-1.9.2-1.i386.rpm