Help with sub-domain deployment?


I have a host (A2 Hosting) that allows me to point different domains
at sub-folders for add-on domain hosting. I’d like to be able to run
diferent rails apps in each of those folders and one in the root also.
I figure I just need to make sure that the first url fragment never
has the name of a sub-folder/site set as a route name?

I’m a little confused on deployment. A2 Hosting says to do a “ln -s
rails_app/public public_html”, but that seems too easy. Not sure what’s
happening there…

They also have Mongrel, which I’m assuming is a server for rails apps?
Is this correct? If so, would it be better to use mongrel? Can mongrel
be setup so a subfolder of the web servers www directory can have
another separate rails app? Like this: - /public_html - /public_html/addonsite

Also, do I need Capistrano? Is that just a deployment helper? Not a
server is it? Ugh, this is all so confusing. And I thought it was soooo
easy to build my first rails app! :slight_smile:

  • matt


 Building the first Rails app is usually easy, deploying it

not :slight_smile:

 I am not sure about A2 setup, most of the shared hosting services

offering cheap accounts with support for Rails use Apache + FastCGI.
This means that Apache administers your Rails app starting it when a
request is received, letting it live for a while and then sutting it
down if no more requests reach Apache for a while (persistent process
are expensive)

 What does Apache + FastCGI expect from your app? A public

directory, including a .htaccess that routes the “dinamic” part of the
app (not the JS and imgaes usually) to dispatach.fcgi. This scripts is
responsible of handling the dinamic stuff in your app, initializing
Rails and feeding it with the request info, waiting for a response and
passing it back to Apache.

If you have a app at your top domain just replace the public_html

(as it is usually named) with a symbolic link to your app public
folder. Be sure to check:

- The path to Ruby interpreter at the top of the script to match

the actual path of the server
- That .htaccess is setup to use the fcgi handler and not the cgi
handler (too slow)
- That you force the production mode in the Rails configuration

About the other apps living in subdomains, I am not sure if they

will be resolved if you create symbolics links in the app/public
folder to their public folder… Give it a try.

I would recommend not to use Capistrano for the first time, until

you finally defined the layout of your setup. Then start working with
Capistrano to automate the deployment process. Capistranos has to be
added to your app, and configured. It relies eavily in SSH and SVN and
in shared hostings it could be a little more difficult to setup.

Good luck.

Aníbal Rojas

On Feb 26, 5:35 pm, Matt M. [email protected]