Rails on Apache


#1

Hi all,

I’m new to rails (and ruby) so be kind :slight_smile:

I have a small server running W2K on which apache (2.0.x) is running
with
the latest version of ruby and rails (I followed the howto on
rubyonrails.org http://rubyonrails.org). However, I want to do the
following:
I have a domain (www.domain.org http://www.domain.org) configured on
the
server as follows:
<VirtualHost *:80>
ServerAdmin removed_email_address@domain.invalid
DocumentRoot D:/data/www/domain.org
ServerName www.domain.org http://www.domain.org
ErrorLog logs/www.domain.org-error_log
CustomLog logs/www.domain.org-access_log common
Alias /h2o d:/data/www/rails.domain.org/h2o/public/
<Directory “d:/data/www/rails.domain.org/h2o/public/”>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi

What I want to do is to serve the h2o application from a different
documentroot than the normal website (which is plain html). No, I don’t
know
if this makes sense or not but bear with me if it remotely does :slight_smile:

The dispatch.fcgi in the public folder has as first line
#!D:/data/apps/ruby/bin/rubyw
As mentioned in the HOWTO

The .htaccess file looks lik this:

General Apache options

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

If you don’t want Rails to look in certain directories,

use the following rewrite rules so that Apache won’t rewrite certain

requests

Example:

RewriteCond %{REQUEST_URI} ^/notrails.*

RewriteRule .* - [L]

Redirect all requests not available on the filesystem to Rails

By default the cgi dispatcher is used which is very slow

For better performance replace the dispatcher with the fastcgi one

Example:

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

RewriteEngine On

If your Rails application is accessed via an Alias directive,

then you MUST also set the RewriteBase in this htaccess file.

Example:

Alias /myrailsapp /path/to/myrailsapp/public

RewriteBase /myrailsapp

#Alias /h2o d:/data/www/rails.apro.be/h2o/public/
RewriteBase /h2o

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

In case Rails experiences terminal errors

Instead of displaying this message you can supply a file here which

will
be rendered instead

Example:

ErrorDocument 500 /500.html

ErrorDocument 500 “

Application error

Rails application failed to
start properly”

Now, the problem is that the application does not work. The URL to start
is
htt://www.domain.org/h2o/account/login. However, this page gives me a
timeout in the logs.

Can someone help me with this?

Many thanks!

BB
Peter


#2

Someone correct me if I’m wrong, but as far as I know Apache 2.0.x is
not very stable with fastcgi. People usually find Apache 1.3.x works
better.

My personal preference is to use “ruby script/server” for
development, and lighttpd on the production server (I have a Virtual
Private Server).

Apache only gave me headaches.

That doesn’t exactly help you out with your issue, just a tip :slight_smile:
cheers, Rob


#3

Hi all,

I’m new to rails (and ruby) so be kind :slight_smile:

I have a small server running W2K on which apache (2.0.x) is running
with
the latest version of ruby and rails (I followed the howto on
rubyonrails.org http://rubyonrails.org). However, I want to do the
following:
I have a domain (www.domain.org http://www.domain.org) configured on
the
server as follows:
<VirtualHost *:80>
ServerAdmin removed_email_address@domain.invalid
DocumentRoot D:/data/www/domain.org
ServerName www.domain.org http://www.domain.org
ErrorLog logs/www.domain.org-error_log
CustomLog logs/www.domain.org-access_log common
Alias /h2o d:/data/www/rails.domain.org/h2o/public/
<Directory “d:/data/www/rails.domain.org/h2o/public/”>
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi

What I want to do is to serve the h2o application from a different
documentroot than the normal website (which is plain html). No, I don’t
know
if this makes sense or not but bear with me if it remotely does :slight_smile:

The dispatch.fcgi in the public folder has as first line
#!D:/data/apps/ruby/bin/rubyw
As mentioned in the HOWTO

The .htaccess file looks lik this:

General Apache options

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

If you don’t want Rails to look in certain directories,

use the following rewrite rules so that Apache won’t rewrite certain

requests

Example:

RewriteCond %{REQUEST_URI} ^/notrails.*

RewriteRule .* - [L]

Redirect all requests not available on the filesystem to Rails

By default the cgi dispatcher is used which is very slow

For better performance replace the dispatcher with the fastcgi one

Example:

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

RewriteEngine On

If your Rails application is accessed via an Alias directive,

then you MUST also set the RewriteBase in this htaccess file.

Example:

Alias /myrailsapp /path/to/myrailsapp/public

RewriteBase /myrailsapp

#Alias /h2o d:/data/www/rails.apro.be/h2o/public/
RewriteBase /h2o

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

In case Rails experiences terminal errors

Instead of displaying this message you can supply a file here which

will
be rendered instead

Example:

ErrorDocument 500 /500.html

ErrorDocument 500 “

Application error

Rails application failed to
start properly”

Now, the problem is that the application does not work. The URL to start
is
htt://www.domain.org/h2o/account/login. However, this page gives me a
timeout in the logs.

Can someone help me with this?

Many thanks!

BB
Peter


#4

On 11/15/05, Robert removed_email_address@domain.invalid wrote:

Someone correct me if I’m wrong, but as far as I know Apache 2.0.x is
not very stable with fastcgi. People usually find Apache 1.3.x works
better.

Apache 2.0 works fine with fastcgid (not fastcgi), which kills old
fastcgi process.

I use a frontend apache because I want to deliver compressed page
through mod_gzip, and as far as I’ve seen it, lighttpd doesn’t support
that (someone confirm?).


#5

Can someone tell me a host where I can deploy a Rails app?
What is the easiest way to do this?
Am I stuck with a colocated server or are there hosted platforms that
make
it easier to deploy and scale?
Anyone?
Thanks in advance!
John B
PS - I know this has multiple answers - just looking for opinions…


#6

On 15 Nov 2005, at 22:16, speechexpert wrote:

Can someone tell me a host where I can deploy a Rails app?
What is the easiest way to do this?
Am I stuck with a colocated server or are there hosted platforms
that make it easier to deploy and scale?
Anyone?
Thanks in advance!

At the moment I know of planet argon and Xeriom.
We’re still testing our Rails platform so you might be better going
for them:

Yours,
Craig

Craig W. | t: +44 (0)131 516 8595 | e: removed_email_address@domain.invalid
Xeriom.NET | f: +44 (0)709 287 1902 | w: http://xeriom.net


#7

On Tue, 2005-11-15 at 22:24 +0000, Craig W. wrote:

for them:
http://www.planetargon.com/

You can ping us on IRC as well…

#planetargon on irc.freenode.net

or via our site:

We don’t just hand you the keys to your ssh account and wish you luck…
we’ll help make sure your site is running smoothly. (been known to even
assist with making a few code changes to help optimize client
applications).

http://www.planetargon.com/hosting.html (rates/plans)

Also, we’ve recently begun offering private IP addresses for +$3/mo so
that you can run Lighttpd on your own port WITHOUT mod_proxy through our
Apache servers. It makes Rails apps just a tad bit faster. :smiley:

I’ve heard good things about Site5 (www.site5.com) as well… but they
don’t offer PostgreSQL. :wink:

Good luck on your quest for good hosting. I know it can be tough.

Cheers,

-Robby


/******************************************************


#8

I haven’t had any problems with Apache2 and fastcgi at all, both on my
iBook (development environment) and on the host where it runs (AMD64
box running Apache2 under Gentoo Linux).

I’ve been having far more difficulty getting lighttpd to work properly
on my iBook with a slightly non-standard (read: no examples on the
net) configuration.

On 11/15/05, Robert removed_email_address@domain.invalid wrote:

That doesn’t exactly help you out with your issue, just a tip :slight_smile:
cheers, Rob


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Chris H.

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard