水曜日, 5月 23, 2012

Linuxにruby1.9.3とrails3.2をインストール


Linux
私の持っている環境のひとつ、さくらのVPSに某プロジェクトでRuby on Railsが必要なのでインストール

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
==========
叩くとエラー
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
185 185 185 185 0 0 562 0 --:--:-- --:--:-- --:--:-- 1850
bash: line 1: html: そのようなファイルやディレクトリはありません
bash: line 2: 期待してない token `<' のあたりにシンタックスエラー
'ash: line 2: `301 Moved Permanently
==========
301だし一時的に落ちてるとかじゃないだろうな
rvmで入れようにも、1.8は使わないだろうしftpで持ってきて入れちゃおうか思案

ただ上記を実際にcurlで持ってくると中身は
==========
#!/usr/bin/env bash

printf "%b" "
Deprecated command, please use:

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

"
false
==========
なので
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
に変更だろうなと検討をつけビンゴ。

==========
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Installing RVM to /usr/local/rvm/
Creating RVM system user group 'rvm'

# RVM: Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /usr/local/rvm/ is almost complete:

* First you need to add all users that will be using rvm to 'rvm' group,
and logout - login again, anyone using rvm will be operating with `umask g+w`.

* To start using RVM you need to run `source /etc/profile.d/rvm.sh`
in all your open shell windows, in rare cases you need to reopen all shell windows.

# root,
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne


rvm 1.13.8 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/]
==========

$ source /etc/profile.d/rvm.sh
して、念の為
$ yum install openssl-devel readline-devel zlib-devel
も入れて
$ rvm install 1.9.3
すると無事エラーもなくruby1.9.3p194が入りました。

gemは
$ gem -v
1.8.24

あとは
$ gem install rails --no-ri --no-rdoc
してrailsも入れます。

sqliteでなくmysqlを使うことが多いので、
rails new project -d mysql
とするのですが、mysql2はうまく入らないことが多い...
gem install mysql2
だとエラーが出て、
gem install mysql2 --with-mysql-include=/usr/include/mysql
と、PATHを指定してあげる必要あり。

特に几帳面に最低限のパッケージしか入れていない方は
/usr/include/mysql
自体がなかったりします。
その場合は
$ yum install --enablerepo=remi mysql-devel
で入れてあげる必要ありです。

その後無事
new project -d mysql
が通ります

現在記事を書いている段階での最新環境であるruby1.9とrails3.3の組み合わせが問題なく動作するさくらのVPSはおオススメです。
2012年3月以前までであれば値段見合いで迷うところでしたが、3月からのスペックアップでだいぶ安くなりましたね。

以前は自宅にサーバ置いて
「自宅データセンター」「自宅第一NOC」
と言っていた方もここまで下がったら、さくらのVPSを借りてしまったほうがトータルでは安上がりでしょうね。

金曜日, 5月 18, 2012

Amazon Web Service の SES/Simple Email Service



AWSのSES 略語ばかりだと何を言ってるのか自分でもわからなくなるのですが、 2011年12月にAmazonがメール大量配信のサービスをリリースしました
http://aws.amazon.com/jp/ses/

設定方法などは
http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.MTAs.SecureTunnel.html
http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.MTAs.Postfix.html
に沿うと設定が可能です。
日本語のほうが設定しやすい際は
http://blog.suz-lab.com/2011/12/postfixsesstunnnel.html このあたりがよいかもしれません。
ただし、大量配信という性質上、Amazonもセキュリティの手綱をゆるめることはできないため、"正しく"送信しないと送れません

http://ash.jp/net/telnet_smtp.htm
このように、インスタンスからtelnetでメール送信ができますが、例えばRCPTを厳密にしていしないとエラーが出て送信ができないなど。

とはいえ作法に従えば使いやすいサービスです。

ただし、AmazonWebServiceは仕事の関係で私は利用していますが価格面でははっきり言って高いです。
いろいろな環境を利用してきましたが、個人や少人数に近い方であれば現段階ではさくらのVPSが一番投資対効果が高いです。