SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
May 18, 2006, 13:39 #1
- Join Date
- Jun 2002
- Location
- Montana, USA
- Posts
- 647
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Practical Questions Regarding Rails
There is a question that has been eating away at the back of my mind regarding Rails -- how does one run multiple applications on the same webserver?
Suppose I have three applications:
Depot
CleverWikiName
NewBlogIdea
Normally, I could easily work on any of these three, simply by starting the WEBrick server that is neatly placed in the script directory after I generate the skeleton.
I would access them thusly, after starting their respective servers (one at a time, or on different ports:
http://.../depot
http://.../clever_wiki_name
http://.../new_blog_idea
and let the default route take them to public/index.html.
Now, the $1,000,000 question is:
How can I set up my (WEBrick, if possible) server so that I can have all three applications running at the same time, on the same port?
Further, how can I set up my WEBrick/Apache server so that I can have (say) a rails application in
http://.../depot
and a regular CGI ruby application in
http://.../hiki
Thanks!Ryan
-
May 18, 2006, 19:24 #2
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I am sure there are others who have more robust solutions, but for the couple of examples I was playing around with at home, I set up a reverse proxy in my apache server to redirect various subdirectory to differnt instances of webbrick running behind my firewall. Something like:
Code:ProxyRequests On ProxyVia On ProxyPass /app1/ http://localhost:3000/
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
May 19, 2006, 04:28 #3
Is there any particular reason you don't want to set up separate subdomains/domains as VirtualHosts? That's what I do for local Apache/Rails development.
-
May 19, 2006, 04:59 #4
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think the example I posted was localhost, but when I was actually playing with it, rails was running on a differernt box behind my firewall. I think the reverse proxy was the easiest way to expose it on a standard port.
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
May 19, 2006, 07:24 #5
- Join Date
- Jun 2002
- Location
- Montana, USA
- Posts
- 647
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by vgarcia
Originally Posted by sweatje
Thank you both for your ideas. I guess I was just looking at the problem the wrong wayRyan
-
May 19, 2006, 08:30 #6
- Join Date
- Jun 2002
- Location
- Montana, USA
- Posts
- 647
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok, update.
I tried using the apache-reverse-proxy technique, and it didn't quite work out for me. It would successfully forward to the WEBBrick server, yes, but all of the relative URLs in the application itself were screwed up (url_for() obviously doesn't itself know about the proxy/forwarding going on in Apache). I could maybe have changed this by editing some configuration in Apache or Rails, but "convention over configuration" is the whole reason I'm doing the Rails thing, so that didn't seem like the appropriate path to take.
I found a little apache module called "scgi" (which, unlike the fastcgi module, worked) and it's associated ruby library (conveniently packaged as a .gem), installed it, ran it in my rails apps directory so that it could create some configuration information, and then added some info to my httpd.conf script, and viola! I'm running 3 apps on one server just as I wanted.
For anyone else whom this may help, this is where I got the information.Ryan
-
May 25, 2006, 09:01 #7
As far as running multiple apps on WebBrick it is very easy just use -p <portnumber). just type it in the command line for example:
Code:script/server -p 3500
Stop Global
Bookmarks