2011年11月13日星期日

Set up Ruby Rails Environment in a Windows 7 box with the help of cygwin

Currently, I decide to learn a web developing framework. Hence the previous good experience in github, Ruby(and Rails) seems to be a good choice.

Without a minute's hesitation, I download the official windows installer and click it ... Oops, my ruby installation cannot find a usable compiler, thus impossible to build modules written in C code. So, cygwin become my first alternative that could provide full-power *nix-like experience.

When using cygwin, the setup process is identical to what you do in linux. So if you have some knowledge of how to use gnu autotools to build and install a software distributed in tarball, you'll be very familar with these steps below:
$ wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
$ tar xf ruby-1.9.3-p0.tar,gz && cd ruby-1.9.3-p0
$ ./configure && make && make install

Then, in order to run Rails, you must build the ruby-openssl extension:
cd ext/openssl
ruby extconf.rb
$ make && make install
  • Perhaps you will need to install libopenssl-devel package in the cygwin setup.exe.
Cygwin is a simulation layer above native windows,  occasionally you will meet this address conflict error. Don't be frightened, in cygwin console run rebaseall to remap all executable in bin directory.
In addition, you could run this command for special executables or dynamic libraries.
$ cd /usr/local/lib/ruby/1.9.1/i386-cygwin
$ rebase -d -b 0x68000000 -o 0x10000 etc.so

Now, you can use ruby as usual(follow the official instruction):
  • install ruby gem 
  • use gem to install rails
  • test rails

没有评论:

发表评论