Archive for ‘ May, 2008

Linux(Vine Linux 4.2)でRARファイルを解凍しよう!

ということで、LinuxでRARファイルを解凍するために、Unrarをインストール
してみた。

ダウンロードは、以下のサイトから。

[rarsoft]
http://www.rarsoft.com/rar_add.htm

まずバイナリをダウンロードしてインストールしようとしたら失敗した。
ということで、成功したほうを書いておく。

(成功)

ダウンロードする。

$ wget http://www.rarlab.com/rar/unrarsrc-3.7.8.tar.gz
$ tar xvfz unrarsrc-3.7.8.tar.gz
$ cd unrar
$ make -f makefile.unix

コンパイルされていることを確認する。

$ ls -l | grep unrar

コンパイルしたunrarをコピーする。

$ cp unrar /usr/local/bin
$ which unrar
$ unrar –help

以下のコマンドで解凍することが出来る。

$ unrar e xxx.rar

(失敗)

$ wget http://www.rarlab.com/rar/rarlinux-3.7.1.tar.gz
$ tar xvfz rarlinux-3.7.1.tar.gz
$ cd rar
$ ./unrar
./unrar: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

何かライブラリが足りないらしい。ということで試行錯誤・・・

$ make
$ apt-get install libstdc++34
$ unrar
unrar: /lib/i686/libc.so.6: version `GLIBC_2.4' not found (required by unrar)

あきらめた。

Read more

Popularity: 12% [?]

  • Digg
  • Google Bookmarks
  • Google Reader
  • Facebook
  • Delicious
  • FriendFeed
  • Evernote
  • Twitter
  • Share/Bookmark

.htaccessで携帯のみアクセス許可にする

ということで、前回各キャリアのIPアドレスを調べたので、.htaccessで携帯のみ
アクセス許可とする。

<Limit GET POST>
        Order deny,allow
        Allow from 210.153.84.0/24
        Allow from 210.136.161.0/24
        Allow from 210.153.86.0/24
        Allow from 123.108.236.0/24
        Allow from 123.108.237.0/27
        Allow from 202.179.204.0/24
        Allow from 202.253.96.224/27
        Allow from 210.146.7.192/26
        Allow from 210.146.60.192/26
        Allow from 210.151.9.128/26
        Allow from 210.169.130.112/28
        Allow from 210.175.1.128/25
        Allow from 210.228.189.0/24
        Allow from 211.8.159.128/25
        Allow from 210.169.40.0/24
        Allow from 210.196.3.192/26
        Allow from 210.196.5.192/26
        Allow from 210.230.128.0/24
        Allow from 210.230.141.192/26
        Allow from 210.234.105.32/29
        Allow from 210.234.108.64/26
        Allow from 210.251.1.192/26
        Allow from 210.251.2.0/27
        Allow from 211.5.1.0/24
        Allow from 211.5.2.128/25
        Allow from 211.5.7.0/24
        Allow from 218.222.1.0/24
        Allow from 61.117.0.0/24
        Allow from 61.117.1.0/24
        Allow from 61.117.2.0/26
        Allow from 61.202.3.0/24
        Allow from 219.108.158.0/26
        Allow from 219.125.148.0/24
        Allow from 222.5.63.0/24
        Allow from 222.7.56.0/24
        Allow from 222.5.62.128/25
        Allow from 222.7.57.0/24
        Allow from 59.135.38.128/25
        Allow from 219.108.157.0/25
        Allow from 219.125.151.128/25
        Allow from 219.125.145.0/25
        Allow from 121.111.231.0/25
        Allow from 121.111.231.160/27
        Allow from 121.111.227.0/25
        Deny from all
</LIMIT>
 

Read more

Popularity: 6% [?]

  • Digg
  • Google Bookmarks
  • Google Reader
  • Facebook
  • Delicious
  • FriendFeed
  • Evernote
  • Twitter
  • Share/Bookmark

各携帯キャリアごとのIPアドレス帯域

ちょっと調べたので書いておく。
各携帯キャリアごとのIPアドレス帯域。(5月16日現在)

変更される可能性があるので、参考URLも。

DoCoMo

iモード
210.153.84.0/24
210.136.161.0/24
210.153.86.0/24

フルブラウザ
210.153.87.0/24

参考URL:
http://www.nttdocomo.co.jp/service/imode/make/content/ip/

SoftBank
123.108.236.0/24
123.108.237.0/27
202.179.204.0/24
202.253.96.224/27
210.146.7.192/26
210.146.60.192/26
210.151.9.128/26
210.169.130.112/28
210.175.1.128/25
210.228.189.0/24
211.8.159.128/25

参考URL:
http://developers.softbankmobile.co.jp/dp/tech_svc/web/ip.php

AU

210.169.40.0/24
210.196.3.192/26
210.196.5.192/26
210.230.128.0/24
210.230.141.192/26
210.234.105.32/29
210.234.108.64/26
210.251.1.192/26
210.251.2.0/27
211.5.1.0/24
211.5.2.128/25
211.5.7.0/24
218.222.1.0/24
61.117.0.0/24
61.117.1.0/24
61.117.2.0/26
61.202.3.0/24
219.108.158.0/26
219.125.148.0/24
222.5.63.0/24
222.7.56.0/24
222.5.62.128/25
222.7.57.0/24
59.135.38.128/25
219.108.157.0/25
219.125.151.128/25
219.125.145.0/25
121.111.231.0/25
121.111.231.160/27
121.111.227.0/25

参考URL:
http://www.au.kddi.com/ezfactory/tec/spec/ezsava_ip.html

 

Read more

Popularity: 9% [?]

  • Digg
  • Google Bookmarks
  • Google Reader
  • Facebook
  • Delicious
  • FriendFeed
  • Evernote
  • Twitter
  • Share/Bookmark

初めてのRuby!!Passenger(mod_rails)を使ってチュートリアルしてみた

前回に続き、今度はチュートリアルを作成してみる。
まず、Railsを試すように適当にアカウントを作った。

# useradd test
# passwd test
(パスワード入力)

ついでに、MySQLのアカウントも作っておく。

# mysql -u root -p
(パスワード入力)
# GRANT ALL PRIVILEGES ON *.* TO test@localhost IDENTIFIED BY 'password' WITH GRANT OPTION

testのユーザディレクトリに入って早速作ってみる。
参考にしたのは、以下のチュートリアル。

http://www.onlamp.com/pub/a/onlamp/
2006/12/14/revisiting-ruby-on-rails-revisited.html
(と思ったが、途中でバージョンが違うのか出来なかったので予定変更)

よし、さっそくということで。

# su – test
(パスワード)

まずは、プロジェクトを作らないといけないらしい。
ということで、以下のコマンドを。
今回、データベースにMySQLを使うので"-d mysql"をつけた。

# rails -d mysql cookbook

なんかわらわらといっぱい作成出来たらしい。
ということで、まずはhttpd.confでバーチャルドメインの設定をしてあげる。

# vim /etc/apache2/conf/httpd.configure
(以下を追加)
<VirtualHost *:80>
    ServerAdmin test@xxxx.xxx
    DocumentRoot /home/test/cookbook/public
    ServerName test.xxxx.xxx
    CustomLog logs/test_access_log combined
    ErrorLog logs/test_error_log
    <Directory /home/test/cookbook/public>
        AllowOverride All
    </Directory>
</VirtualHost>

ということで、次はRailsのデータベースの設定を変更してやる。

# vim cookbook/config/database.yml
(サンプル)
development:
  adapter: mysql
  encoding: utf8
  database: cookbook_development
  username: dev
  password: passwd
  socket: /var/lib/mysql/mysql.sock

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  encoding: utf8
  database: cookbook_test
  username: dev
  password: passwd
  socket: /var/lib/mysql/mysql.sock

production:
  adapter: mysql
  encoding: utf8
  database: cookbook_production
  username: dev
  password: passwd
  socket: /var/lib/mysql/mysql.soc

次にデータベースに、先ほど設定した内容を反映させる。
具体的には、MySQL上にデータベースが作成される。

# cd cookbook
# rake db:create:all

次に、Cookbookのテーブル定義とスクリプトを生成する。

# ruby script/generate scaffold Cookbook title:string body:text due:datetime
 

解説
Cookbook テーブル名
title:string以下 カラム定義

# rake db:migrate

以上!!
たった、ちょっとのRailsのコマンドだけでCookbookというテーブルと
それの管理画面が出来てしまった。便利すぎる。

ということで、以下のアドレスにアクセスして確認。

http://test.xxxx.xxx/cookbooks/

と、インターナルエラーがでてしまった。
どうやら、原因は、参照先に該当するテーブルがないらしい。

先ほどのデータベースの設定で、上記のようにアクセスすると
プロダクション側のデータベースを見にいっている。

ということで、面倒だったので以下の様に変更してしまった。

# vim config/database.yml
(以下を変更)
production:
  adapter: mysql
  encoding: utf8
  database: cookbook_development
  username: dev
  password: passwd
  socket: /var/lib/mysql/mysql.soc

で再度アクセス。
素晴らしい。

Read more

Popularity: 7% [?]

  • Digg
  • Google Bookmarks
  • Google Reader
  • Facebook
  • Delicious
  • FriendFeed
  • Evernote
  • Twitter
  • Share/Bookmark

初めてのRuby!!Passenger(mod_rails)をとりあえず入れてみて

今まで、Rubyっていうものは聴いたことはあったけど、一度も触ったことがなかった。
なんとなく、Ruby on Railsには興味はあったし、どんなものかも知っていたけど、
実行環境を作るのが面倒くさそうだった。

が、なんかmod_railsというのが出たらしい。
結構簡単に、環境が作れるらしい。

ということで、早速インストールしてみることにした。

前提:
以下が既にインストール済みとする。
Apache2
Ruby 1.8以降?

まず、どうやらRuby関係の何かを入れるためにgemsというのが必要らしい。
ということで、インストール。
aptであったので、さっくりとaptから。

# apt-get install rubygems

あとで、知ったことだがここでとりあえずgemsをアップデートしておいた
ほうがいいらしい。(たぶん)
(自分の場合は失敗して、再インストールすることになってしまった)

# gem update –system

でさっそく、Passenger(mod_rails)をインストールしようとしたら・・・。

# gem install passenger
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR:  While executing gem … (Gem::GemNotFoundException)
    Could not find passenger (> 0) in any repository 

なんか怒られてしまった。
どうやら、railsを先にいれないといけないらしい。
Railsってつまりは、Ruby on RailsをやるためのFrameworkかな?

ということで、さっくりとインストール。
これも、gemsから出きるらしい。

# gem install -v=2.0.2 rails -y
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rails-2.0.2
Successfully installed rake-0.8.1
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
Successfully installed actionpack-2.0.2
Successfully installed actionmailer-2.0.2
Successfully installed activeresource-2.0.2
Installing ri documentation for rake-0.8.1…
Installing ri documentation for activesupport-2.0.2…
Installing ri documentation for activerecord-2.0.2…
Installing ri documentation for actionpack-2.0.2…
Installing ri documentation for actionmailer-2.0.2…
Installing ri documentation for activeresource-2.0.2…
Installing RDoc documentation for rake-0.8.1…
Installing RDoc documentation for activesupport-2.0.2…
Installing RDoc documentation for activerecord-2.0.2…
Installing RDoc documentation for actionpack-2.0.2…
Installing RDoc documentation for actionmailer-2.0.2…
Installing RDoc documentation for activeresource-2.0.2…

気を取り直して、Passenger(mod_rails)のインストール。
これもやっぱり、先ほどと一緒でgemsから。

# gem install passenger
…………
complete
Install required dependency fastthread? [Yn]  y
Select which gem to install for your platform (i386-linux)
 1. fastthread 1.0.1 (mswin32)
 2. fastthread 1.0.1 (ruby)
 3. fastthread 1.0.1 (i386-mswin32)
 4. Skip this gem
 5. Cancel installation
> 2
Building native extensions.  This could take a while…
Building native extensions.  This could take a while…
Successfully installed passenger-1.0.5
Successfully installed fastthread-1.0.1
Installing ri documentation for passenger-1.0.5…
Installing ri documentation for fastthread-1.0.1…

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump
Installing RDoc documentation for passenger-1.0.5…
Installing RDoc documentation for fastthread-1.0.1…

No definition for dummy_dump

No definition for dummy_dump

No definition for rb_queue_marshal_load

No definition for rb_queue_marshal_dump
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:25: warning: already initialized constant FONTS
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:235: warning: already initialized constant STYLE
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:246: warning: already initialized constant XHTML_PREAMBLE
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:289: warning: already initialized constant HEADER
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:310: warning: already initialized constant FOOTER
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:335: warning: already initialized constant FILE_PAGE
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:384: warning: already initialized constant CLASS_PAGE
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:604: warning: already initialized constant METHOD_LIST
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:621: warning: already initialized constant BODY
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:640: warning: already initialized constant SRC_PAGE
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:649: warning: already initialized constant FR_INDEX_BODY
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:675: warning: already initialized constant FILE_INDEX
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:677: warning: already initialized constant CLASS_INDEX
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:678: warning: already initialized constant METHOD_INDEX
/usr/lib/ruby/1.8/rdoc/generators/template/html/html.rb:704: warning: already initialized constant INDEX

で仕上げに、以下をやらないといけないらしい。

# passenger-install-apache2-module
—-
passenger-install-apache2-module
Welcome to the Passenger Apache 2 module installer, v1.0.5.

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.
1
Checking for required software…

 * GNU C++ compiler… found at /usr/bin/g++
 * Ruby development headers… found
 * OpenSSL support for Ruby… found
 * RubyGems… found
 * Rake… found at /usr/bin/rake
 * Apache 2… found at /usr/sbin/apache2
 * Apache 2 development headers… found at /usr/bin/apxs
 * Apache Portable Runtime (APR) development headers… found at /usr/bin/apr-1-config
 * fastthread… found
——————————————–

——————————————–
Compiling and installing Apache 2 module…
cd /var/lib/gems/1.8/gems/passenger-1.0.5
rake clean apache2
(in /var/lib/gems/1.8/gems/passenger-1.0.5)
### In ext/apache2:
rm -rf Utils.o Logging.o Configuration.o Hooks.o mod_passenger.o mod_passenger.so

rm -r pkg
### In ext/passenger:
make clean
rm -f Makefile

### In ext/boost/src:
rm -f libboost_thread.a *.o

### In test:
rm -f Apache2ModuleTests *.o

### In benchmark:
rm -f DummyRequestHandler

### In ext/boost/src:
g++ -O2 -fPIC -I../.. -D_REENTRANT -DNDEBUG  -c *.cpp
ar cru libboost_thread.a *.o
ranlib libboost_thread.a

### In ext/apache2:
g++ -I.. -fPIC -g -DPASSENGER_DEBUG -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -m32 -march=i386 -mcpu=i686 -I/usr/include/apache2 -D_REENTRANT -Wall -g -I/usr/local/include  -c mod_passenger.c

### In ext/apache2:
g++ -I.. -fPIC -g -DPASSENGER_DEBUG -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -m32 -march=i386 -mcpu=i686 -I/usr/include/apache2 -D_REENTRANT -Wall -g -I/usr/local/include  -c Utils.cpp

### In ext/apache2:
g++ -I.. -fPIC -g -DPASSENGER_DEBUG -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -m32 -march=i386 -mcpu=i686 -I/usr/include/apache2 -D_REENTRANT -Wall -g -I/usr/local/include  -c Logging.cpp

### In ext/apache2:
g++ -I.. -fPIC -g -DPASSENGER_DEBUG -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -m32 -march=i386 -mcpu=i686 -I/usr/include/apache2 -D_REENTRANT -Wall -g -I/usr/local/include  -c Configuration.cpp

### In ext/apache2:
g++ -I.. -fPIC -g -DPASSENGER_DEBUG -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/usr/include/apr-1 -m32 -march=i386 -mcpu=i686 -I/usr/include/apache2 -D_REENTRANT -Wall -g -I/usr/local/include  -c Hooks.cpp

### In ext/apache2:
g++ -shared Utils.o Logging.o Configuration.o Hooks.o mod_passenger.o -fPIC -o mod_passenger.so   -lstdc++ -lpthread ../boost/src/libboost_thread.a -lapr-1

### In ext/passenger:
ruby extconf.rb
creating Makefile

### In ext/passenger:
make
gcc -I. -I/usr/lib/ruby/1.8/i386-linux -I/usr/lib/ruby/1.8/i386-linux -I.  -fPIC -O2 -m32 -march=i386 -mcpu=i686  -fPIC  -c native_support.c
gcc -shared -rdynamic -Wl,-export-dynamic   -L'/usr/lib' -Wl,-R'/usr/lib' -o native_support.so native_support.o  -Wl,-R -Wl,/usr/lib -L/usr/lib -L. -lruby  -lpthread -ldl -lcrypt -lm   -lc

——————————————–
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-1.0.5/ext/apache2/mod_passenger.so
   RailsSpawnServer /var/lib/gems/1.8/gems/passenger-1.0.5/bin/passenger-spawn-server
   RailsRuby /usr/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.

——————————————–
Deploying a Ruby on Rails application: an example

Suppose you have a Ruby on Rails application in /somewhere. Add a virtual host
to your Apache configuration file, and set its DocumentRoot to
/somewhere/public, like this:

   <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public
   </VirtualHost>

And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:

  /var/lib/gems/1.8/gems/passenger-1.0.5/doc/Users guide.html

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

すばらしい。
エラーもなく案外あっさりとインストールできてしまった。
しかも、最後に、httpd.confの設定例まで表示された。

httpd.confの設定は後回しにして。
ついでに、RubyとMySQLを連携させるためのモジュールらしきものもいれておく。
(これが必要なのかは確認していない・・・)

# apt-get install MySQL-ruby

これできっと完璧。
ということで、httpd.confの編集。

# vim /etc/apache2/conf/httpd.conf
(以下を追加)
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-1.0.5/ext/apache2/mod_passenger.so
RailsSpawnServer /var/lib/gems/1.8/gems/passenger-1.0.5/bin/passenger-spawn-server
RailsRuby /usr/bin/ruby

ということで、Apacheを再起動。

# service apache2 restart

ということで、一通りインストールは完了した。

Read more

Popularity: 6% [?]

  • Digg
  • Google Bookmarks
  • Google Reader
  • Facebook
  • Delicious
  • FriendFeed
  • Evernote
  • Twitter
  • Share/Bookmark

Linux(VineLinux)にZendFrameworkをインストールしてみる

といっても、とっても簡単。
まず、以下のサイトからダウンロードを行う。

[ZendFramework]
http://framework.zend.com/

ダウンロード(2008/5/1の最新版)

# wget http://framework.zend.com/releases/ZendFramework-1.5.0/
ZendFramework-1.5.0.tar.gz

解凍

# tar xvfz ZendFramework-1.5.0.tar.gz

PHPのライブラリを置く専用のディレクトリを作成する。
今回は"/usr/local/lib/php"とする。

# mkdir -p /usr/local/lib/php

先ほど解凍したファイルを上記ディレクトリへ移動

# mv ZendFramework-1.5.0/library/* /usr/local/lib/php

あとは、php.iniに上記パスを追加してやる。
自分の場合は、常にZendFrameworkを使うわけではないので、「.htaccess」ファイル
に以下の設定をしてあげることで、PATHを通すことにした。

# vim .htaccess
(以下ファイルの内容)
php_value include_path ".:/usr/local/lib/php/"

これで、ZendFrameworkを使うことが出来る。

Read more

Popularity: 8% [?]

  • Digg
  • Google Bookmarks
  • Google Reader
  • Facebook
  • Delicious
  • FriendFeed
  • Evernote
  • Twitter
  • Share/Bookmark