Hello world

I have a web server (apache2) that I want to host my ruby app on. So
far I’ve been unsuccessful in getting a hello world app to work. I’ve
tried playing around with my virtual host file to get it to point to my
index.html.erb. I’ve tried playing around with the config/routes.rb to
get it to work. But so far no luck. Can someone point to me to a howto
on getting my hello world app to work, or shed some light on some common
problems? I’m running Ubuntu 7.10, apache2, rails 2.0 (I think). I
have my ruby app in my example.com/ directory which has the typical
rails folders (app, config, etc). Thanks in advance for the help!

Mickey

Hi,

Deploying Rails apps can be tricky.

The issue is, you need a web gateway to your program (in other words,
requests have to come into the webserver, and then the webserver has
to run rails with ruby SOMEhow)… the .htaccess file in rails public
folder is set up to do CGI serving by default.

The easiest (but really really crappy) way if you’re using Apache is
probably going to be to use cgi.

You need to ensure that your docroot of the virtual host is pointing
to the public folder of your app.

Better than this is fastCGI, but it’s not incredibly good. (To use
fastcgi, you’ll need to change the .htaccess file slightly, and ensure
you have mod_fastcgi turn on in your apache conf file)

The best way (at present) if you’re using apache is to use mod_proxy
and mod_proxy_balancer to proxy to a cluster of mongrels.

That way, apache will serve your static stuff, and mongrel will serve
your dynamic stuff.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

Thanks for your reply Julian.

It sounds like getting Ruby and Rails to work with Apache might take
some playing around with. I’d like to try to get it to work, but at the
same time I’m committed to learning Ruby and it seems that Mongrel is
the preferred way to go, sooo… Is it really better to go the Mongrel
route than the Apache route? What kind of advantages are there to
Mongrel. When I hear about open source web servers, Apache is always
the first I hear about. That’s the reason I started with it. Thanks in
advance for any advice!

Mickey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Julian L. wrote:
|
| 1. Ruby is slow(er than comparative web technologies).
| 2. Deploying Ruby things to the web is a bitch.

Unless you use JRuby, Warbler/Goldspike, and Glassfish or another Java
application server, that is.

http://wiki.jruby.org/wiki/Success_Stories
http://wiki.jruby.org/wiki/JRuby_on_Rails_in_GlassFish

If it’s good enough for Oracle, it’s probably good enough for you, too.
:stuck_out_tongue:

| We’ll (most likely) end up with mod_rubinius, which will simply plug

I guess that Passenger will hit the market sooner (mod_rails, to to
speak)…


Phillip G.
Twitter: twitter.com/cynicalryan

~ - You know you’ve been hacking too long when…
…you’re awakened by your SO and all you can think of, in that muddied
half-conscious state before becoming fully awake, is something having to
do with male and female serial connectors and how the baud rates have to
be synchronized.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkf9hoIACgkQbtAgaoJTgL+8pgCgnxO0ybt5eW0V2sInoBJTwtVs
7+sAniWQ+qoDPa4bC1ILbk1uhuHiKsrX
=IbNp
-----END PGP SIGNATURE-----

Apache is good. It’s solid, fast and stable.

Apache can’t run ruby apps, though.

If you were using PHP, you’d just use the mod_php plugin in apache and
that’d be that… apache would call mod_php for every time it needed
to compile a php file, and you’d be happy as larry and almost none the
wiser (not really needing to know much about how it works).

We’re using Rails, though, and mod_ruby is crappy, so we don’t use it.

Thus, we’re left with a few options - cgi, fastcgi, all whole slew of
other things that run ruby apps on “proxy” for apache (where apache
simply sends the requests over to these other mini-servers, one of
which is mongrel), etc.

The reason I recommended cgi at first, is that it doesn’t require
setting up any other things. A cluster of mongrels requires that you
have something that starts and stops them.

Now, the disadvantage of cgi is that it’s really quite slow, AND it
does some odd things with taking up huge amounts of resources (both
kinds: CPU power and Memory/space).

The “next hardest” is fastCGI. FastCGI is faster, but it still has its
own issues (memory leaks, sometimes hard to configure, etc) and it’s
biggest disadvantage is that you have to deal with killing it and
sometimes it just won’t die properly, etc. (it’s a bitch to manage,
basically).

The disadvantage of a mongrel_cluster is, as I said, you have to
manage its starting and stopping, which includes (i’m not sure what
platform you’re on) setting up rc.d files, or adding things to OS/X’s
launchd config.

In other words, YOU have to manage it.

The reason Evan P. and EngineYard are putting so much effort into
rubinius, which you may or may not have heard of is that it will fix
rails and ruby’s two major issues:

  1. Ruby is slow(er than comparative web technologies).
  2. Deploying Ruby things to the web is a bitch.

We’ll (most likely) end up with mod_rubinius, which will simply plug
into apache or nginx or something else and all our server issues will
be moot.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

No, if you use JRuby, deploying apps is still a bitch compared to php.

Mind you, deploying cake is a bitch, too (cake being the PHP framework
equivalent of rails) because of it’s (somewhat) “full stack” nature.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Julian L. wrote:

A: Becasue it makes it difficult to understand the context.
Q: WHy is top-posting bad.

| No, if you use JRuby, deploying apps is still a bitch compared to php.

Never had to mess around with UNIX file permissions, then, I guess?

Or PHP timeouts and other limitations for more complex apps (like
TikiWiki)?

Application servers are well established, and trimmed for stability with
the least amount of administrative fuss.

See, considering that application servers are mostly used in corporate
environments, where people get paid for their time, it makes sense to
optimize for simplicity and stability.

As far as deployment goes:
Create a JRuby WAR with Warbler or Goldspike, and drop it into the
deployment folder of your application server. If you happen to have a
cluster, it is usually deployed across the whole cluster.

Heck, NetBeans 6.0.x ships with (optional) additional rake tasks to
build a WAR file, if you so desire.

Beats using something like an Apache with a Mongrel pack by far. And
even fiddling with read-write permissions (not to mention securing a
mod_php or CGI environment).

And only one thing to administer, too (since you can let an application
server listen on port 80, if you wanted).


Phillip G.
Twitter: twitter.com/cynicalryan

10 years old is a good age to get stuck at.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkf9kEIACgkQbtAgaoJTgL+0YACbBQHKqWyPMfAGk0F9K59chpMn
AbYAn19vyMcqq49YejlvFK2jnG0YoNLi
=9a22
-----END PGP SIGNATURE-----

Dude!

I’ve had to deploy apps in LOADS of different ways, across many
different languages. (C++ / CORBA / SmallTalk / Java / WebObjects /
PHP / Rails / Merb / Other)

How to start deploying a PHP app:

simple as drag 'n drop in FTP.

This makes it EASIER.

That’s ALL I’m saying. It’s not that EASY in Rails. We know this. I’m
not advocating any of the other frameworks or languages, or anything.
You come from a Java background, fair enough, but setting up a Java
environment to host in is not a particularly trivial affair. It’s less
trivial than a cluster of mongrels on apache with mod proxy and
balancer.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/

Wow, I hate to break up the debate, but here’s a useful resource for
Mickey:

http://articles.slicehost.com

If you want to set up a production server, then check out the articles
there. I found them very helpful, though I am still learning more
about Apache. At this point, you don’t have to decide what you think
is the “best” solution - just get something working.

On that note, if you’re just learning, run in development mode on your
local machine:

ruby script/server

Even WEBrick is good enough for learning. Deal with deploying later.

-Kyle

On Apr 9, 11:42 pm, Phillip G. [email protected]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Julian L. wrote:
| Dude!
|
| I’ve had to deploy apps in LOADS of different ways, across many
| different languages. (C++ / CORBA / SmallTalk / Java / WebObjects /
| PHP / Rails / Merb / Other)
|
| How to start deploying a PHP app:
|
| simple as drag 'n drop in FTP.
|
| This makes it EASIER.

And Java Appserver work similarly. Except it’s one file, in one
directory, and scalability depending on how much hardware you throw at
it.

Where as PHP and other languages need solutions with proxying, etc.

| That’s ALL I’m saying. It’s not that EASY in Rails. We know this. I’m
| not advocating any of the other frameworks or languages, or anything.

No need to get defensive. Deployment via JRuby is one option among many,
and simpler than setting up a Mongrel cluster, IMO (and less chance of
failure, too, since that risk rises exponentially to the elements used).

| You come from a Java background, fair enough, but setting up a Java
| environment to host in is not a particularly trivial affair. It’s less
| trivial than a cluster of mongrels on apache with mod proxy and
| balancer.

Not at all am I coming from a Java background (and proud of it :P). But
I’m willing to look at what is available there, and tap into the
knowledge that is available in that area.

And that is higher than the knowledge available in regard to Mongrel and
Apache, LigHTTPd, or other webservers.

And infrastructure-wise, Java is miles ahead of anyone. That’s a serious
benefit of its deployment across a wide range of businesses, and most in
Enterprises with a Big E (defined for this purpose as corporations that
don’t have software as a core business, but as a support function for
the actual core business. Banks, grocers, etc.).

And fortunately, it is relatively easy to get Java and Glassfish
installed on most Linux flavors and Mac OS X (X Server): Download
packages, untar them, run the installers (adjust file permissions if
necessary). However, with more, er, exotic UNICES it does get tricky.

Another benefit is, that Java application servers scale almost
automatically. Not so a more traditional Rails approach of deploying an
Apache + Mongrel cluster.

And anything that makes my life easier is worth consideration, IMO.

But so would be another deployment option.

In any case: Proper Planning Prevents Punishable Poor Performance.


Phillip G.
Twitter: twitter.com/cynicalryan

~ Hobbes : How is the diorama coming along?
~ Calvin : I’m almost finished.
~ Hobbes : I don’t see the roadrunner. Weren’t you going to put one
in?
~ Calvin : See the cotton balls I glued down?
~ Hobbes : Yeah?
~ Calvin : The roadrunner just ran out of the scene leaving behind
clouds of dust!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkf9mqYACgkQbtAgaoJTgL+rOgCfT6GoNT3oT44bdVFOEUX6sVxP
7roAn3FS2yslMmyZGry8QRuVAt/Ox89c
=aI98
-----END PGP SIGNATURE-----

Thanks all for the help. I do have a simple Ruby app working in my
development environment (WEBrick), but my attempts to deploy it on my
web server have been discouraging. I’ll check that link out after work
Kyle, thanks for that. But I’m definitely ready for the deployment
stage (proof of concept, before I finish my development).

I do think it might be worth my time to investigate Mongrel (even though
I was biased towards Apache from the start). Is it possible to run both
web servers on the same machine without conflict and on the same port
(80)? Perhaps through the virtual host mechanism?

Thanks again guys.
Mickey

The reading will help, but here’s basically what happens in a typical
(if there is such a thing) Apache/Mongrel setup:

Apache receives the request
Apache sees if the request is for a static file
—If so, Apache serves the file
—If not, Apache proxies the request to Mongrel

That’s very simplistic, but it’s basically what happens if you set up
your server like slicehost lays out. So, to answer your question,
yes, you can (and will) run both servers on the same machine and the
same port.

-Kyle

On Apr 10, 11:14 am, Mickey C. [email protected]

Hi, have you had the opportunity to look at mod_rails? If not, I would
recommend taking alook at the following:

http://www.modrails.com/

Good luck,

-Conrad

On Wed, Apr 9, 2008 at 6:12 PM, Mickey C. <

Here’s the full error. Any ideas welcome. Thanks in advanced.
Mickey

ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install mongrel --include-dependencies
extconf.rb:1:in `require’: no such file to load – mkmf (LoadError)
from extconf.rb:1

Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1 for inspection.
Results logged to
/usr/lib/ruby/gems/1.8/gems/fastthread-1.0.1/ext/fastthread/gem_make.out
INFO: gem install -y is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Building native extensions. This could take a while…

Hi Conrad,

Thanks for the link. Looks like something I’d like to try out. When I
tried to install it “sudo gem install passenger”, I get the following
error:

ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.

Any ideas? Thanks for the help!
Mickey

On 23 Apr 2008, at 03:02, Mickey C. wrote:

Here’s the full error. Any ideas welcome. Thanks in advanced.
Mickey

It looks like you don’t have the stuff needed to build ruby extensions.

Fred

What do I need to build ruby extensions? I’ve done:

“sudo apt-get install build-essential”

but I still have the problem. Thanks.

Mickey

Hey Mickey, did you following the instructions on the following page:
http://www.modrails.com/documentation/Users%20guide.html

I guess the most important steps are:

section 2.2
section 2.3

Let me know and I’ll talk to you later.

Good luck,

-Conrad

On Wed, Apr 23, 2008 at 5:39 AM, Mickey C. <

Thanks guys. You all have been a great resource in learning this stuff
:slight_smile: It looks like I’ve gotten a lot closer to being able to deploy my
Ruby app. I ran through the list of items to install that Mack posted
on his blog and there were several that hadn’t been installed yet.

One of the instructions of configuring Passenger is to copy some lines
from the config to the apache configuration file (which I assume is the
/etc/init.d/apache2 file). It doesn’t say where to add it, so I append
it to the end of the file and get the following error:

Instructions that the config says to add:

LoadModule passenger_module
/usr/lib/ruby/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so
RailsSpawnServer
/usr/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server
RailsRuby /usr/bin/ruby1.8

and here’s the error I get when I do “sudo /etc/init.d/apache2 restart”:

/etc/init.d/apache2: 206: LoadModule: not found

Any ideas what to do here? Thanks again for the help.
Mickey

I did a write-up on my experience getting mod_rails running on Ubuntu.
Should work for Debian as well. For your situation, just ignore
everything from the ‘Get Typo’ header on down.

http://macksmind.net/2008/04/13/installing-typo-blog-engine-and-mod_rails-for-multiple-accounts/

-Mack
macksmind.net

On Wed, Apr 23, 2008 at 8:39 AM, Mickey C.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs