Tuesday, April 24, 2007

Virtues of Monoculture, Or Why Microsoft Wins.

I found a very good piece of writing that points out many things I was confused about for a long time. This article precisely and sharply points out all my doubts with Open Source. So, I am now even more confused while struggling with Ruby and AJAX, REST and GWT... But I definitely know, that once you (or I) get to the .Net side "You’re always going to be running on a Windows platform. You got the pretty gold ring, but Sauron gets to pull your strings and make you dance."


Virtues of Monoculture, Or Why Microsoft Wins.

Monday, April 23, 2007

CookBook on Rails

Ok.

Since Eclipse is downloaded and runs perfectly (see previous post), I went to the Ruby side again.

Let me note that before struggling with Eclipse I had some stuff installed (see below), and I am going to use it now.
1. Ruby 1.8.5
2. Ruby Gems 0.9.2 (extract, then run "ruby setup.rb")
3. Rails ("gem install rails --include-dependencies")
4. MySQL 5.0 which was installed as the service at mysql://localhost:3306

Now we are setting up the Eclipse environment:
The Ruby setup:


The Rails setup:




At this point I am able to create a Rails project through ..->New Project -> Rails Project -> ... It runs and makes some "standard Rails welcome" output in browser.



Time to configure MySQL.
To work with MySQL stuff I've decided to use old good Eclipse Data Tools Platform (DTP) which employs connector/J from MySQL.
To setup Rails MySQL connector stuff I run "gem install mysql" and choose first (1) option.

At this point I have MySQL running as service, and Eclipse DTP and Rails are ready to connect it. In Eclipse I configured MySQL connectivity: ...->Preferences->Connectivity->...


And now we can use SQL Explorer ...


... or Data View to fix our databases and run the example from OnLamp.com: Rolling with Ruby on Rails Revisited

Saturday, April 21, 2007

Continuing the Ruby way... (Windows)

So, I've installed Ruby at my Windows machine along with RDT and RadRails Eclipse plugins and my Eclipse went wrong. It doesn't want to load, it cannot update due to some insane dependencies...

So, I've decided to reinstall Eclipse.

Since I am using WTP, at first I got it downloaded from IBM, but id didn't want to update, I've tried WTP site and this distros didn't work also. I got empty Eclipse and tried to install all my stuff, but it died on update again.

And after I found the best Eclipse configurator ever! Take a look at it at Innoopract. It does has all needed packages and plugins: I use Java, WTP, CDT, EPIC and RDT with dozens of plugins and tools. I got em all as the one zip, unzipped and working on Ruby skills now.

Friday, April 13, 2007

Went for mod_fcgid instead of mod_fastcgi

Getting the module
 
# wget http://prdownloads.sourceforge.net/mod-fcgid/mod_fcgid.2.1.tar.gz?download


Need to fix Makefile so it point to /usr/share/apache2 and add copy couple of the libraries from /usr/include/apache2-prefork to /usr/include/apache2: mpm.h and mpm_common.h to avoid this error:


# /tmp/mod_fcgid.2.1 # make
/usr/lib64/apr-1/build/libtool --silent --mode=compile gcc -I. -O2 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -DAP_DEBUG -DSSL_EXPERIMENTAL_ENGINE -DMAX_SERVER_LIMIT=200000 -DLDAP_DEPRECATED -DMAXLINE=4096 -I/usr/include/apache2 -I. -I/usr/include/apr-1 -prefer-pic -c arch/unix/fcgid_proc_unix.c && touch fcgid_proc_unix.slo
In file included from arch/unix/fcgid_proc_unix.c:13:
/usr/include/apache2/mpm_common.h:46:17: error: mpm.h: No such file or directory
In file included from arch/unix/fcgid_proc_unix.c:13:
/usr/include/apache2/mpm_common.h:349: error: expected ')' before '*' token
make: *** [fcgid_proc_unix.slo] Error 1


So it make:

# make
# strip .libs/mod_fcgid.so
# make install


This has to be added to httpd.conf:

This is for fastcgi-mode Ruby on Rails ( Thank Andre Nathan giving me this demo configuration )

LoadModule fcgid_module modules/mod_fcgid.so
SocketPath /tmp/fcgidsock
SharememPath /tmp/fcgidshm
DefaultInitEnv RAILS_ENV production

<Directory /home/sneakymustard/tumble/public>

    Options ExecCGI FollowSymLinks

    AllowOverride AuthConfig Indexes Limit

    Order allow,deny


    Allow from all



    AddHandler fcgid-script .fcgi


    # You need
mod_fcgid version >= 2.1 to support arguments "xxx/dispatch.fcgi" in
FCGIWrapper

    FCGIWrapper "/usr/bin/ruby
/home/sneakymustard/tumble/public/dispatch.fcgi" .fcgi



    RewriteEngine On


    RewriteRule ^$ index.html [QSA]

    RewriteRule ^([^.]+)$ $1.html [QSA]

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

</Directory>


along with

AddHandler fastcgi-script fcgi

<Directory /srv/www/htdocs/>
AllowOverride All
Options FollowSymLinks
</Directory>

<Directory /srv/www/rails/*/public/>
Allow from all
</Directory>


and

SocketPath /tmp/fcgidsock
AddHandler fcgid-script fcgi


Edit the
APACHE_MODULES
line in
/etc/sysconfig/apache2
by inserting “fcgid” and removing “fastcgi”.

HOORAY!

The Ruby Way :-), Руби на рельсах

Thats it. Seeing other people (Robert was the latest victim :-) ) being attracted by Ruby made me thinking that everything is not that bad. So, while running my computations I've decided to see what that beast really is.

1. Using Yast (I have SuSe 10.2) I've installed:

* apache2
* apache2-devel
* apache2-mod_fastcgi
* ruby
* ruby-devel
* ruby-doc-ri
* rubygems
* FastCGI
* FastCGI-devel
* zlib


2. in shell:

* # gem install fcgi
* # gem install mysql
* # install rails -y
* # mkdir /srv/www/rails
* # mkdir /srv/www/fcgi-log
* # chown wwwrun /srv/www/fcgi-log


3. Do a
 # vi /etc/apache2/httpd.conf 
and add


#
# Ruby stuff
#
AddHandler fastcgi-script fcgi

<Directory /srv/www/htdocs/>
AllowOverride All
Options FollowSymLinks
</Directory>

<Directory /srv/www/rails/*/public/>
Allow from all
</Directory>


I've added to
/etc/sysconfig/apache2
in APACHE_MODULES words “rewrite” and “fastcgi”.

4. I think that I am finally done by doing following:

# cd /srv/www/rails
# rails test
# chown -R wwwrun:www test/tmp
# chown -R wwwrun:www test/public
# ln -s /srv/www/rails/test/public /srv/www/htdocs/test
# cd test/public
# vi .htaccess

and adding

RailsFCGIHandler.Process! '/srv/www/fcgi-log/test_fcgi_crash.log'

to the end of .htaccess

AND FINALLY

# rcapache2 start


AND I'VE GOT AN ERROR THAT KEEP ME WORKING FOR 2 HOURS ALREADY:

zhabanet-amd:/srv/www # rcapache2 start
Module "fastcgi" is not installed, ignoring.
Check the APACHE_MODULES setting in /etc/sysconfig/apache2.


I gave up for today...