When your run script/server, it is owned by the parent process, in this case the shell. You don't get your shell back until you kill the server. Now, depending on how you have Rails installed, it may be running one of several servers:
- WEBrick (a Ruby server that is the fall-back option for Rails)
- lighttpd (a very capable general-purpose http server)
- Mongrel (a server that is suited particularly well for Rails applications)
The server command looks in your path to see which of these it can use. The default port for Rails apps is 3000 and if I had to venture a guess as to why, I'd guess it's because it's a high port number that you can selectively protect with a firewall (but I don't know the real answer). If you don't like 3000, just use:
script/server -p 8080
or some other port. If you want to actually start the server as a daemon and get your shell back, then use:
script/server -p 8080 -d
Personally, I use Mongrel for everything and prefer to start it as:
mongrel_rails mongrel::start -d
You can then use:
to manage the server process.
Here's more complete info on script/server:
mycomputer:~/rails/myproj zzzzzz$ script/server --help
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
Usage: server [options]
-p, --port=port Runs Rails on the specified port.
-b, --binding=ip Binds Rails to the specified ip.
-d, --daemon Make server run as a Daemon.
-e, --environment=name Specifies the environment to run this server under (test/development/production).
-h, --help Show this help message.
You almost certainly don't want your Rails app to be located in a world-readable directory like public_html. It'll run just fine anyplace on your machine. I have mine set up:
So now you know about the magic -d option for the server. The final piece of the puzzle is that you need Apache to proxy yourdomain.com to port 3000 or whatever you decide on. Here's a snippet of httpd.conf that will set up a virtual host proxied to a port (I used port 3000 for this example):
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000
Last edited by cwd (2007-01-07 02:54:10)