<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://townx.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>townx - Ruby on Rails on XAMPP with FastCGI for Ubuntu Hoary - Comments</title>
 <link>http://townx.org/ruby_on_rails_on_xampp</link>
 <description>Comments for &quot;Ruby on Rails on XAMPP with FastCGI for Ubuntu Hoary&quot;</description>
 <language>en</language>
<item>
 <title>Hello there. Thanks for the</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-13186</link>
 <description>&lt;p&gt;Hello there. Thanks for the comment. Have a look at my reply to the same error message report below. Unless you are intending on running in a shared hosting environment or with an ancient Apache, Mongrel plus a mod_proxy (and maybe mod_proxy_balancer) is a far better solution for running your Rails applications than Apache plus FastCGI. FastCGI is generally considered a moribund project, and it leaks memory all over the place as well as spawning errant processes. Mongrel is far superior. The scripts for compiling Mongrel, mod_proxy etc. for &lt;span class=&quot;caps&quot;&gt;XAMPP &lt;/span&gt;are part of the AxleGrease project (the above instructions are about 18 months old now, and Rails deployments are generally moving off FastCGI onto Mongrel).&lt;/p&gt;</description>
 <pubDate>Sun, 24 Dec 2006 13:08:17 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 13186 at http://townx.org</guid>
</item>
<item>
 <title>Make errors on Ubuntu Edgy</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-13185</link>
 <description>&lt;p&gt;I attempted to install mod_fastcgi using the method shown above and this is what I got:&lt;/p&gt;

&lt;p&gt;$ make top_dir=/opt/lampp&lt;br /&gt;
/opt/lampp/build/libtool --silent --mode=compile gcc -pthread  -O6 -I/opt/lampp/include -L/opt/lampp/lib  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE    -I/opt/lampp/include -I. -I/home/lampp/apache/httpd-2.2.3/srclib/apr/include -I/home/lampp/apache/httpd-2.2.3/srclib/apr-util/include -I/opt/lampp/include -prefer-pic -c mod_fastcgi.c &amp;amp;&amp;amp; touch mod_fastcgi.slo&lt;br /&gt;
mod_fastcgi.c: In function &#039;init_module&#039;:&lt;br /&gt;
mod_fastcgi.c:270: error: &#039;ap_null_cleanup&#039; undeclared (first use in this function)&lt;br /&gt;
mod_fastcgi.c:270: error: (Each undeclared identifier is reported only once&lt;br /&gt;
mod_fastcgi.c:270: error: for each function it appears in.)&lt;br /&gt;
mod_fastcgi.c: In function &#039;process_headers&#039;:&lt;br /&gt;
mod_fastcgi.c:725: warning: return makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:729: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:739: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:768: warning: initialization makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:838: warning: return makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:842: warning: return makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;set_uid_n_gid&#039;:&lt;br /&gt;
mod_fastcgi.c:1022: warning: passing argument 1 of &#039;memcpy&#039; makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:1024: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:1033: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:1034: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;do_work&#039;:&lt;br /&gt;
mod_fastcgi.c:2321: error: &#039;ap_null_cleanup&#039; undeclared (first use in this function)&lt;br /&gt;
mod_fastcgi.c: In function &#039;create_fcgi_request&#039;:&lt;br /&gt;
mod_fastcgi.c:2479: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2492: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;apache_is_scriptaliased&#039;:&lt;br /&gt;
mod_fastcgi.c:2534: warning: initialization makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;post_process_for_redirects&#039;:&lt;br /&gt;
mod_fastcgi.c:2559: warning: passing argument 1 of &#039;ap_internal_redirect_handler&#039; makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;check_user_authentication&#039;:&lt;br /&gt;
mod_fastcgi.c:2682: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2700: warning: comparison between pointer and integer&lt;br /&gt;
mod_fastcgi.c: In function &#039;check_user_authorization&#039;:&lt;br /&gt;
mod_fastcgi.c:2749: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2765: warning: comparison between pointer and integer&lt;br /&gt;
mod_fastcgi.c: In function &#039;check_access&#039;:&lt;br /&gt;
mod_fastcgi.c:2809: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2826: warning: comparison between pointer and integer&lt;br /&gt;
make: *** [mod_fastcgi.slo] Error 1&lt;/p&gt;


&lt;p&gt;Is there anyway that I can possibly download a precompiled mod_fastcgi.so?&lt;/p&gt;</description>
 <pubDate>Sun, 24 Dec 2006 04:01:12 -0600</pubDate>
 <dc:creator>Hyperair</dc:creator>
 <guid isPermaLink="false">comment 13185 at http://townx.org</guid>
</item>
<item>
 <title>Thanks</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-13101</link>
 <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Thanks, works great! &lt;/p&gt;

&lt;p&gt;Great projects you do elliot, lot of people will be happy for this, so do i :-)&lt;/p&gt;

&lt;p&gt;I use fastcgi on production servers (RHEL). On ubuntu (laptop), the set up of xampp/rails without fastcgi was a bit slow,&lt;br /&gt;
thanks for the mongreil solution.&lt;/p&gt;

&lt;p&gt;Again, nice project !&lt;/p&gt;

&lt;p&gt;Franky&lt;/p&gt;</description>
 <pubDate>Tue, 28 Nov 2006 19:40:06 -0600</pubDate>
 <dc:creator>Franky</dc:creator>
 <guid isPermaLink="false">comment 13101 at http://townx.org</guid>
</item>
<item>
 <title>Hi Franky. To be honest, I</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-13100</link>
 <description>&lt;p&gt;Hi Franky. To be honest, I haven&#039;t done too much compilation of FastCGI on Dapper: I prefer to use Mongrel now instead. I don&#039;t really see a reason for using FastCGI unless you are setting up mass hosting of Rails apps. on Apache, e.g. in a hosting provider setting (e.g. Dreamhost and Site5 take this approach). If you are setting up on your own servers, I would recommend Apache 2.2, mod_proxy_balancer and Mongrel instead. If you are stuck with an older Apache, you can use mod_proxy plus a load balancer like Pound (see the howto at &lt;a href=&quot;http://blog.codahale.com/2006/11/07/pound-vs-pen-because-you-need-a-load-balancing-proxy/&quot; title=&quot;http://blog.codahale.com/2006/11/07/pound-vs-pen-because-you-need-a-load-balancing-proxy/&quot;&gt;http://blog.codahale.com/2006/11/07/pound-vs-pen-because-you-need-a-load...&lt;/a&gt;). If you are working with &lt;span class=&quot;caps&quot;&gt;XAMPP &lt;/span&gt;on Linux, you can use my AxleGrease project (&lt;a href=&quot;http://rubyforge.org/projects/rorox/&quot; title=&quot;http://rubyforge.org/projects/rorox/&quot;&gt;http://rubyforge.org/projects/rorox/&lt;/a&gt;), which will do all the hard stuff for you: it includes a recent Apache, Rails, mod_proxy_balancer, Mongrel, etc.. Hope this helps.&lt;/p&gt;</description>
 <pubDate>Tue, 28 Nov 2006 04:14:38 -0600</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 13100 at http://townx.org</guid>
</item>
<item>
 <title>fastcgi make errors</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-13079</link>
 <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;RubyonRails is running on &lt;span class=&quot;caps&quot;&gt;XAMPP &lt;/span&gt;on Ubuntu dapper.&lt;/p&gt;

&lt;p&gt;I have found this post when googling for a howto for installing fastcgi on &lt;span class=&quot;caps&quot;&gt;XAMPP &lt;/span&gt;&amp;amp; ruby.&lt;/p&gt;

&lt;p&gt;Downloaded the mod_fastcgi tarball, but trying to do make, i get following errors:&lt;br /&gt;
mod_fastcgi.c: In function &#039;apache_is_scriptaliased&#039;:&lt;br /&gt;
mod_fastcgi.c:2534: warning: initialization makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;post_process_for_redirects&#039;:&lt;br /&gt;
mod_fastcgi.c:2559: warning: passing argument 1 of &#039;ap_internal_redirect_handler&#039; makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c: In function &#039;check_user_authentication&#039;:&lt;br /&gt;
mod_fastcgi.c:2682: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2700: warning: comparison between pointer and integer&lt;br /&gt;
mod_fastcgi.c: In function &#039;check_user_authorization&#039;:&lt;br /&gt;
mod_fastcgi.c:2749: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2765: warning: comparison between pointer and integer&lt;br /&gt;
mod_fastcgi.c: In function &#039;check_access&#039;:&lt;br /&gt;
mod_fastcgi.c:2809: warning: assignment makes pointer from integer without a cast&lt;br /&gt;
mod_fastcgi.c:2826: warning: comparison between pointer and integer&lt;br /&gt;
etc.&lt;/p&gt;

&lt;p&gt;Do you have any idea what i am missing?&lt;/p&gt;

&lt;p&gt;With kind regards,&lt;/p&gt;

&lt;p&gt;Franky&lt;/p&gt;</description>
 <pubDate>Sun, 26 Nov 2006 19:04:21 -0600</pubDate>
 <dc:creator>Franky</dc:creator>
 <guid isPermaLink="false">comment 13079 at http://townx.org</guid>
</item>
<item>
 <title>Haven&#039;t noticed any socket issues. What...</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-120</link>
 <description>&lt;p&gt;Haven&#039;t noticed any socket issues. What kind of thing do you mean? I haven&#039;t got anything on the web yet, but have been working on some clip log software (for storing and categorising audio interview excerpts). I&#039;ll be putting it up on this site when it&#039;s done, and if I get the time I&#039;ll write some documentation!&lt;/p&gt;
</description>
 <pubDate>Fri, 23 Sep 2005 15:47:57 -0500</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">comment 120 at http://townx.org</guid>
</item>
<item>
 <title>I found the install to be...</title>
 <link>http://townx.org/ruby_on_rails_on_xampp#comment-115</link>
 <description>&lt;p&gt;I found the install to be quite cumbersome for MAC OS X, however once I got it running it has been great. However, recently I have encountered some socket issues. Have you experienced any such issues? Do you know where I can find some help in order to resolve? Also, do you have any ruby apps running on the web. I would love to check it out.&lt;/p&gt;
</description>
 <pubDate>Wed, 21 Sep 2005 13:52:20 -0500</pubDate>
 <dc:creator>trizeysteel</dc:creator>
 <guid isPermaLink="false">comment 115 at http://townx.org</guid>
</item>
<item>
 <title>Ruby on Rails on XAMPP with FastCGI for Ubuntu Hoary</title>
 <link>http://townx.org/ruby_on_rails_on_xampp</link>
 <description>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;I&#039;ve done a lot of tinkering
with Ruby on Rails recently, and thought it might be worth sharing my
experiences with the wider world (I get a few hits on my website from
people looking for &quot;xampp+ruby&quot;, so thought I might be able to help
those folks out).&lt;/p&gt;
&lt;p&gt;This isn&#039;t a full tutorial, and
I&#039;ll assume you understand how to create a database and tables in
MySQL, and navigate your way round a command line. I also won&#039;t go into
the ins and outs of Rails, but will point at far better tutorials that
should help you get to grips with it.&lt;/p&gt;
&lt;p&gt;Getting Ruby on Rails working
is relatively straightforward. I&#039;ll talk about getting it going on
Ubuntu, the Linux distribution I use for development work. The software
you&#039;ll need to get started is as follows:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Ruby - a full install&lt;/li&gt;
  &lt;li&gt;Rails - a Ruby package
available via the gem tool (which you&#039;ll need to install as well)&lt;/li&gt;
  &lt;li&gt;XAMPP - this is a bundle of
software including Apache (the web server to run
your Rails application off of) and&amp;nbsp;MySQL (the database
back-end for your Rails application)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once I installed this lot, I
wrote my first Rails application to prove to myself it was working; so
this tutorial will follow the same pattern, and I&#039;ll give some minimal
instructions about creating a minimal application to prove Rails is
working.&lt;/p&gt;
&lt;p&gt;Then, optionally, you can
install FastCGI to improve the performance of Rails applications (by
default, Rails makes CGI applications). To get FastCGI working with
Rails, you need the following:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;FastCGI - to improve
performance of your Rails application; this works as an Apache module&lt;/li&gt;
  &lt;li&gt;Ruby FastCGI bindings - so
Rails can make use of FastCGI&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Installing Ruby&lt;/h2&gt;
&lt;p&gt;I followed &lt;a
 href=&quot;http://wiki.rubyonrails.com/rails/show/RailsOnUbuntuDebianTestingAndUnstable&quot;&gt;these
instructions&lt;/a&gt; to install a full
Ruby. If you are using Ubuntu, this boils down to running the following
command as root:&lt;/p&gt;
&lt;pre&gt;apt-get install \&lt;br /&gt; irb1.8 \&lt;br /&gt; libbigdecimal-ruby1.8 \&lt;br /&gt; libcurses-ruby1.8 \&lt;br /&gt; libdbm-ruby1.8 \&lt;br /&gt; libdl-ruby1.8 \&lt;br /&gt; libdrb-ruby1.8 \&lt;br /&gt; liberb-ruby1.8 \&lt;br /&gt; libgdbm-ruby1.8 \&lt;br /&gt; libiconv-ruby1.8 \&lt;br /&gt; libopenssl-ruby1.8 \&lt;br /&gt; libpty-ruby1.8 \&lt;br /&gt; libracc-runtime-ruby1.8 \&lt;br /&gt; libreadline-ruby1.8 \&lt;br /&gt; librexml-ruby1.8 \&lt;br /&gt; libruby1.8 \&lt;br /&gt; libruby1.8-dbg \&lt;br /&gt; libsdbm-ruby1.8 \&lt;br /&gt; libsoap-ruby1.8 \&lt;br /&gt; libstrscan-ruby1.8 \&lt;br /&gt; libsyslog-ruby1.8 \&lt;br /&gt; libtest-unit-ruby1.8 \&lt;br /&gt; libwebrick-ruby1.8 \&lt;br /&gt; libxmlrpc-ruby1.8 \&lt;br /&gt; libyaml-ruby1.8 \&lt;br /&gt; libzlib-ruby1.8 \&lt;br /&gt; rdoc1.8 \&lt;br /&gt; ri1.8 \&lt;br /&gt; ri \&lt;br /&gt; rdoc \&lt;br /&gt; ruby \&lt;br /&gt; ruby1.8 \&lt;br /&gt; ruby1.8-dev \&lt;br /&gt; libmysql-ruby1.8 \&lt;br /&gt; ruby1.8-examples&lt;br /&gt;&lt;/pre&gt;
&lt;h2&gt;Installing Rails&lt;/h2&gt;
&lt;p&gt;Rails can be installed via the
gem tool for Ruby, which is kind of an apt for Ruby. It is possible
that there are Debian packages for Rails, but I&#039;ve been using the
manual install method so I get the latest Rails.&lt;/p&gt;
&lt;p&gt;Before you can install Rails,
you will need to download and install gem first, like this:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Grab the latest tarball
version from &lt;a href=&quot;http://rubyforge.org/frs/?group_id=126&quot;&gt;http://rubyforge.org/frs/?group_id=126&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Unpack it somewhere:&lt;br /&gt;
    &lt;code&gt;cd ~&lt;br /&gt;
tar zxvf&amp;nbsp;rubygems-0.8.11.tgz&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;As root, connect to the
unpacked directory and run:&lt;br /&gt;
    &lt;code&gt;ruby setup.rb&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Once you&#039;ve done this, you
can get the latest version at any time using this command as root:&lt;br /&gt;
    &lt;code&gt;gem install rubygems&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To install Rails, as root do:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;gem
install rails -v 0.13.0&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Note that I&#039;d suggest installing this version of Rails (0.13.0), as at
the time
of writing the latest version (0.13.1) is not supported under the
version of Ruby packaged for Ubuntu. If you install this later version,
it will refuse to work with the installed version of Ruby.
&lt;/p&gt;
&lt;h2&gt;Installing XAMPP&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://www.apachefriends.org/en/xampp.html&quot;&gt;XAMPP&lt;/a&gt;
is a really nice way of getting a LAMP stack up and working quickly. It
comes packaged with Apache, MySQL, PHP (4 and 5), Perl, phpmyadmin, and
phpsqlliteadmin, so you get a full stack up and running quickly. It&#039;s
not suitable for production use out of the box, but can be tailored to
make it secure.&lt;/p&gt;
&lt;p&gt;To install XAMPP, follow these
instructions:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Download it from &lt;a
 href=&quot;http://www.apachefriends.org/en/xampp-linux.html&quot;&gt;here&lt;/a&gt;.
I used version 1.4.14.&lt;/li&gt;
  &lt;li&gt;Unpack it into the /opt
directory as root:&lt;br /&gt;
    &lt;code&gt;cp
xampp-linux-1.4.14.tar.gz /opt&lt;br /&gt;
cd
/opt&lt;br /&gt;
tar zxvf&amp;nbsp;xampp-linux-1.4.14.tar.gz&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Start XAMPP as root using:&lt;br /&gt;
/&lt;code&gt;opt/lampp/lampp start&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;That&#039;s it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Full instructions for running
it are given on the &lt;a
 href=&quot;http://www.apachefriends.org/en/xampp.html&quot;&gt;XAMPP
website&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Creating a first Rails
application&lt;/h2&gt;
&lt;p&gt;My first Rails application was
built with help from &lt;a
 href=&quot;http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html&quot;&gt;these
instructions&lt;/a&gt;, which are very
good. However, I wanted to run my applications with Apache, rather than
the Webrick built-in web server which Rails is bundled with. So here&#039;s
my set of minimal instructions for writing a Rails application to run
inside Apache.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;First thing you&#039;ll need is a
database. Create one in MySQL called &lt;code&gt;cdcollection&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Create a user with
privileges on that database only: I called my user &lt;code&gt;cdcollection&lt;/code&gt;.
As far as I can tell, you only need to give this user SELECT, UPDATE,
DELETE and INSERT privileges on the database.&lt;/li&gt;
  &lt;li&gt;One other wrinkle: the MySQL
client libraries in Ruby do not support the latest MySQL authentication
protocol, as used by MySQL 4.1 (and included in XAMPP 1.4.14). So that
our &lt;code&gt;cdcollection&lt;/code&gt;
user can connect to the database, you need to update the &lt;code&gt;mysql.user&lt;/code&gt;
table like this:&lt;br /&gt;
    &lt;code&gt;USE mysql;&lt;br /&gt;
UPDATE user SET password = OLD_PASSWORD(&amp;lt;password&amp;gt;) WHERE
user=&#039;cdcollection&#039;;&lt;/code&gt;&lt;br /&gt;
    &lt;code&gt;FLUSH PRIVILEGES;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Add a table to the database
called &lt;code&gt;cds&lt;/code&gt;.
Rails is quite exacting about what you call your database tables, and
it&#039;s easiest to use plurals (this upsets me too, but let it pass). Give
it three fields: &lt;code&gt;id&lt;/code&gt;
(int, unsigned, not null,
autoincrement, primary key), &lt;code&gt;title&lt;/code&gt;
(varchar, 255
characters, not null), &lt;code&gt;artist&lt;/code&gt;
(varchar, 255 characters,
not null).&lt;/li&gt;
  &lt;li&gt;Put some records into the &lt;code&gt;cds&lt;/code&gt;
table so Rails has something to display.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We&#039;re now ready to create our
Rails application.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Create the base application
like this:&lt;br /&gt;
    &lt;code&gt;rails ~/cdcollection&lt;/code&gt;&lt;br /&gt;
The argument you pass to the rails command specifies the directory
where the base application should be installed. &amp;nbsp;Note that
this is outside XAMPP&#039;s DocumentRoot directory: I tend to build the
application externally to XAMPP, and symlink it into the DocumentRoot
(which we&#039;ll do later).&lt;/li&gt;
  &lt;li&gt;Calling this command creates
a standard directory structure for your application, common to all
Rails applications. This directory structure is described &lt;a
 href=&quot;http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=2&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;The next things we have to
edit are the &quot;shebang&quot; lines at the top of the scripts which Rails
relies on. You can find where Ruby is located using &lt;code&gt;whereis
ruby&lt;/code&gt;, which should give you
the path you need to supply as the shebang for the scripts. You can do
a global replace using this Ruby command:&lt;br /&gt;
    &lt;code&gt;ruby -i -pe
&#039;gsub!(&quot;#!/usr/local/bin/ruby&quot;, &quot;#!/usr/bin/ruby&quot;)&#039;
~/cdcollection/public/dispatch.* ~/cdcollection/script/*&lt;/code&gt;&lt;br /&gt;
(I&#039;ve found that the default shebang in Rails 0.13.0 is &lt;code&gt;/usr/bin/ruby1.8&lt;/code&gt;,
which works fine in Ubuntu.)
  &lt;/li&gt;
  &lt;li&gt;Edit the database
configuration file (&lt;code&gt;~/cdcollection/config/database.yml&lt;/code&gt;)
so
it looks
like this:&lt;br /&gt;
    &lt;pre&gt;development:&lt;br /&gt; adapter: mysql&lt;br /&gt; database: cdcollection&lt;br /&gt; host: localhost&lt;br /&gt; username: cdcollection&lt;br /&gt; password: &amp;lt;password&amp;gt;&lt;br /&gt; socket: /opt/lampp/var/mysql/mysql.sock&lt;/pre&gt;
Note the extra &lt;code&gt;socket&lt;/code&gt;
line in this file: this is
necessary because XAMPP&#039;s MySQL socket runs in a different location
from the default, so you have to tell Ruby where the socket is.&lt;br /&gt;
Note that I haven&#039;t edited the production and test database
environments specified in this configuration file: you will need to do
this once you start serious
development. &lt;/li&gt;
  &lt;li&gt;Create an initial model,
controller and view for our &lt;code&gt;cds&lt;/code&gt;
table. Rails provides scripts for creating basic MVC code for doing
CRUD operations on a database table.&lt;br /&gt;
    &lt;code&gt;cd ~/cdcollection&lt;br /&gt;
ruby script/generate scaffold cd&lt;/code&gt;&lt;br /&gt;
This operation adds some files into the app directory. We now have
enough code to run our application.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The last step is to link our
directory into our XAMPP DocumentRoot and set its permissions, so we
can do something with it:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;code&gt;ln
-s &amp;lt;path_to_home_dir&amp;gt;/cdcollection/public
/opt/lampp/htdocs/cdcollection&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;chown
-R nobody.users &amp;lt;path_to_home_dir&amp;gt;/cdcollection&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;chmod
-R g+w &amp;lt;path_to_home_dir&amp;gt;/cdcollection&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To see the application,
navigate to &lt;strong&gt;http://localhost/cdcollection/cds&lt;/strong&gt;.
Note that if you go to &lt;strong&gt;http://localhost/cdcollection/&lt;/strong&gt;,
you will just get the default &quot;Rails is working&quot; message.&lt;/p&gt;
&lt;p&gt;Hopefully, you should see a
list of the CDs you entered into your database, and be able to add,
edit, update and delete them. This means Rails is working fine, using
CGI to run.&lt;/p&gt;
&lt;p&gt;You can now follow these
excellent tutorials to improve your Rails application:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.linuxjournal.com/article/8217&quot;&gt;Exploring
Ruby on Rails&lt;/a&gt; (Linux Journal)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html&quot;&gt;Rolling
with Ruby on Rails (Part 1)&lt;/a&gt;
(ONLamp.com)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html&quot;&gt;Rolling
with Ruby on Rails (Part 2)&lt;/a&gt;
(ONLamp.com)&lt;/li&gt;
  &lt;li&gt;&lt;a
 href=&quot;http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html&quot;&gt;Ajax
on Rails&lt;/a&gt; (ONLamp.com)&lt;/li&gt;
  &lt;li&gt;&lt;a
 href=&quot;http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf&quot;&gt;Four
days on Rails&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&quot;http://api.rubyonrails.com/&quot;&gt;Rails API
documentation&lt;/a&gt; is also very good,
and you will find this &lt;a
 href=&quot;http://www.ruby-doc.org/docs/ProgrammingRuby/&quot;&gt;online
book&lt;/a&gt; handy if you are also
trying to learn Ruby at the same time.&lt;/p&gt;
&lt;h2&gt;Installing FastCGI&lt;/h2&gt;
&lt;p&gt;The next step is to improve
performance of our Rails application so it runs under FastCGI, rather
than standard CGI. (NB it is also theoretically possible to run Rails
applications under &lt;a href=&quot;http://www.modruby.net/en/&quot;&gt;mod_ruby&lt;/a&gt;,
but I couldn&#039;t get this working.) Here&#039;s &lt;a
 href=&quot;http://www.fastcgi.com/&quot;&gt;an explanation of
FastCGI and what it&#039;s for&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Because I was running XAMPP,
and there&#039;s no FastCGI package for XAMPP, I built one from the FastCGI
source. The first thing you need to do is get the XAMPP Development
package and unpack this on top of your XAMPP installation:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Get the development package
from:&lt;br /&gt;
    &lt;a href=&quot;http://www.apachefriends.org/en/xampp-linux.html&quot;&gt;http://www.apachefriends.org/en/xampp-linux.html&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Unpack it:&lt;br /&gt;
    &lt;code&gt;cp&amp;nbsp;xampp-linux-devel-1.4.14.tar.gz
/opt&lt;br /&gt;
cd /opt&lt;br /&gt;
tar zxvf xampp-linux-devel-1.4.14.tar.gz&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Next thing you need is the
source distribution of FastCGI:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Download the tarball from &lt;a href=&quot;http://fastcgi.com/dist/&quot;&gt;http://fastcgi.com/dist/&lt;/a&gt;;
you need the &lt;em&gt;mod_fastcgi&lt;/em&gt;
tarball (I used version 2.4.2).&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;tar
zxvf mod_fastcgi-2.4.2.tar.gz&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;cd
mod_fastcgi-2.4.2&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;mv
Makefile.AP2 Makefile&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Edit &lt;code&gt;Makefile&lt;/code&gt;
and change
the &lt;code&gt;top_dir&lt;/code&gt;
variable so its value is &lt;code&gt;/opt/lampp&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;make&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;make
install&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This installs a &lt;code&gt;mod_fastcgi&lt;/code&gt;
module into XAMPP&#039;s modules directory
(/opt/lampp/modules/mod_fastcgi.so).&lt;/p&gt;
&lt;p&gt;Now edit Apache&#039;s configuration
file (/opt/lampp/etc/httpd.conf) so that this module is loaded. I did
this by adding the following lines to the file:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;LoadModule
fastcgi_module modules/mod_fastcgi.so&lt;br /&gt;
&amp;lt;IfModule mod_fastcgi.c&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;FastCgiIpcDir /opt/lampp/tmp/fcgi/&lt;br /&gt;
&amp;nbsp;&amp;nbsp;AddHandler fastcgi-script .fcgi&lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You will also need to add the
fcgi directory to your XAMPP installation and set its permissions, i.e.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mkdir
/opt/lampp/tmp/fcgi&lt;br /&gt;
mkdir /opt/lampp/tmp/fcgi/dynamic&lt;br /&gt;
chown -R nobody.root /opt/lampp/tmp/fcgi&lt;br /&gt;
chmod -R 777 /opt/lamp/tmp/fcgi&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Note that this gives
read/write/execute permissions on this directory to anybody. I&#039;m sure
there is a better way to do this, and welcome suggestions :)&lt;/p&gt;
&lt;p&gt;You will need to reload Apache
for this to take effect. Hopefully, you should now have mod_fastcgi
installed and working. Check the error_log file just to make sure
FastCGI is not throwing any errors.&lt;/p&gt;
&lt;h2&gt;Installing Ruby FastCGI
bindings&lt;/h2&gt;
&lt;p&gt;We will also need the FastCGI
development kit to install the Ruby bindings for FastCGI:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Get the source tarball
from&amp;nbsp;&lt;a href=&quot;http://fastcgi.com/dist/&quot;&gt;http://fastcgi.com/dist/.&lt;/a&gt;
You will need the fcgi tarball.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;tar
zxvf fcgi-2.4.0.tar.gz&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;cd
fcgi-2.4.0&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;./configure
--prefix=/opt/fastcgi&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;make
install&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note that this installs the
development kit into &lt;code&gt;/opt/fastcgi&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To install the Ruby bindings for FastCGI:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Get the latest tarball of
ruby-fcgi from &lt;a href=&quot;http://sugi.nemui.org/pub/ruby/fcgi/&quot;&gt;http://sugi.nemui.org/pub/ruby/fcgi/&lt;/a&gt;.
I got it working with version 0.8.6.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;tar
zxvf ruby-fcgi-0.8.6.tar.gz&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;cd
ruby-fcgi-0.8.6&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;ruby
install.rb config --
--with-fcgi-include=/opt/fastcgi/include
--with-fcgi-lib=/opt/fastcgi/lib&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;ruby
install.rb setup&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;ruby
install.rb install&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Editing the Rails application
to use FastCGI&lt;/h2&gt;
&lt;p&gt;The last step is to configure the Rails application to make use of
FastCGI. You can do this by editing the &lt;code&gt;~/cdcollection/public/.htaccess&lt;/code&gt;
file as follows:&lt;/p&gt;
&lt;p&gt;Change the line:&lt;br /&gt;
&lt;code&gt;RewriteRule ^(.*)$ /dispatch.cgi?$1 [QSA,L]&lt;/code&gt;&lt;br /&gt;
to&lt;br /&gt;
&lt;code&gt;RewriteRule ^(.*)$ /dispatch.fcgi?$1 [QSA,L]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If you now return to your application in the browser, you should see
a noticeable improvement in speed.&lt;/p&gt;
&lt;p&gt;That&#039;s about all you need to do to get Rails running under FastCGI
on Ubuntu. It&#039;s a bit scrappy and complicated at the moment, but
hopefully before too long someone will start making the packages we
need for this...&lt;/p&gt;</description>
 <comments>http://townx.org/ruby_on_rails_on_xampp#comments</comments>
 <category domain="http://townx.org/howtos">howtos</category>
 <pubDate>Tue, 19 Jul 2005 09:04:00 -0500</pubDate>
 <dc:creator>elliot</dc:creator>
 <guid isPermaLink="false">135 at http://townx.org</guid>
</item>
</channel>
</rss>
