Topic: Run several Rails apps and Radiant on one web server?

I am pretty new to rails development and I like many aspects of it ... also the ease of how one can quickly start a web server running the application.

However, I do not understand how to go about when one would develop a couple of separate web applications, each in their own rails directory and then wants to have them run all on one server in production mode? What if I want to have my web applications and Radiant run on the same server?

I am also worried by what I hear about problems with FastCGI under Apache -- so is there a simple way to e.g. use the server that comes with rails to run several rails apps and Radiant side by side on the same server?

Is there a "standard" or recommended way how to solve this?

Re: Run several Rails apps and Radiant on one web server?

It depends on what hosting provider you have - as well as if you're talking about running them on the same domain or just the same computer.  If you're on Dreamhost then you can easily add new sites via their panel.  If you're on a VPS (Slicehost.com, railsmachine.com, etc.) then it's a little tricker.

Here's the real issue:
A piece of software is running your Rails app (whether it's mongrel, apache, lighttpd, or something else).  You can run as many instances of this software as you want in as many varieties - so long as you have enough CPU and memory in the computer.  The tricky part is making certain programs respond to certain domain names or ports.

So the answer is definitely yes.  you can run several Rails apps.  How you do that depends on what server configuration you have.

Do you already have a hosting account or are you looking for one?

Re: Run several Rails apps and Radiant on one web server?

This is supposed to run on a single, existing domain. It also should run on a single computer. So hosting is not a problem, this is already existing.

Currently, during development, I have three seperate applications, two rails applications rails1 and rails2 which I test on ports 3000 and 3001 and radiant, which I run under port 3002.

Suppose I have domain www.somedomain.com ... what I would like to do is configure everything in a way so that I have rails1 running as www.somedomain.com/rails1, rails2 running as www.somedomain.com/rails2 and radiant running as www.somedomain.com/radiant, all of them of course running on the default port 80.

Re: Run several Rails apps and Radiant on one web server?

Rails can be told to function in a subdirectory simply by setting:
ActionController::AbstractRequest.relative_url_root = "/rails2"

How you get all the apps to respond on the same port depends on the server software you use.  With Apache you'd just let the .htaccess file in each application's public folder run the Rails app for that directory.

If you want to use Mongrel instead of Apache+fastcgi then it's tricker.  You'd have to run them behind some kind of proxy (nginx, pound, Apache) or else you'd be stuck with the different port numbers.

Do you know what software you plan to use?

Re: Run several Rails apps and Radiant on one web server?

Ideally this would run under Apache, but I have heard bad things about fastcgi, so I would prefer to avoid that.

I find the idea of using a proxy to bundle several independently running servers very appealing ... that way we would be free to eventually run e.g. rails1 on a different computer.

Re: Run several Rails apps and Radiant on one web server?

Look into a ubuntu setup, and use the deprec + capistrano gems. You'll save yourself a lot of headache.

Last edited by DFischer (2007-05-09 20:30:14)

http://danielfischer.com - Personal Web-Technology-Blog, Los Angeles.

Re: Run several Rails apps and Radiant on one web server?

Yeah, it's very nice to be able to leverage proxies.  It makes things really easy when it's time to grow.

If you want to run this under Apache you just need to Google around for mod_proxy and experiment with virtual host configurations.  It might take you an hour or two but it's completely doable.

If it's at all possible though I'd recommend you go with Nginx.  It's this new server that's developed in Russia.  Small, incredibly fast, very configurable.  I run a whole cluster of Rails sites under it and it's never let me down.  Plus, it's pretty easy to configure with proxies.  If you decide to use Nginx let me know - I could probably help you out with the configuration.

Re: Run several Rails apps and Radiant on one web server?

Deprec is pretty awesome.  If you've got access to a bare machine (typically a VPS) that you can install Ubuntu on then it's a great way to go.  If that doesn't apply or if you don't want Apache then there's plenty of alternatives.

Re: Run several Rails apps and Radiant on one web server?

Thanks for all the info ... I will do some research on the options you listed here.
smile