negonicrac / webfaction-rails-environment forked from rzownir/webfaction-rails-environment
- Source
- Commits
- Network (3)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
README.markdown | Mon Jan 05 01:30:33 -0800 2009 | |
| |
extra.sh | Mon Jan 05 01:30:33 -0800 2009 | |
| |
webfaction.sh | Mon Jan 05 01:30:33 -0800 2009 | |
| |
webfaction_passenger.sh | Sun Jun 21 15:42:20 -0700 2009 |
WebFaction Rails Stack
The accompanying shell script will automatically build and configure your own
private Ruby on Rails/Merb stack. It was written with
WebFaction users in
mind, but is more or less generic aside from a few minor details. Essentially,
the directories $HOME/logs/user and $HOME/webapps/$APP_NAME must exist
before running the script.
What's Provided
- Ruby 1.8.7 (latest from the 1.8.7 subversion branch)
- RubyGems 1.3.1 (plus subsequent updates, if any)
- Gems: rails, merb, mongrel, mongrel_cluster, thin, capistrano, termios, ferret, acts_as_ferret, god, sqlite3-ruby, mysql, and typo
- Git 1.6.1
- nginx 0.6.34 (with nginx-upstream-fair module for fair load balancing)
- Monit 4.10.1
- Startup scripts and working default configuration files for monit and nginx
Before Running the Script
- Create a rails app from the WebFaction control panel. Leave the autostart box unchecked.
- Create an app of type "custom application (listing on port)" from the WebFaction control panel. Name it monit.
- Assign values to the four variables at the beginning of the script:
PREFIX,APP_NAME,APP_PORT, andMONIT_PORT.PREFIXis the installation path prefix. It is the location of your "private application environment". It should be somewhere in your home directory. It has a default value of$HOME/apps. You could make it$HOME, but the home directory contains things that are better off separate. With a compartmentalizedPREFIXlike$HOME/apps, if you aren't happy with your setup, you could simply kill the monit, nginx, and thin processes, executerm -rf $HOME/appsand start over fresh.APP_NAMEis the name of the app created in step one. The path$HOME/webapps/$APP_NAMEshould exist and contain at least a skeleton app. The default value forAPP_NAMEistypo.APP_PORTis the port WebFaction assigned to the app created in step one. The default value is4000.MONIT_PORTis the port WebFaction assigned to the app created in step two. The default value is4002.
After Running the Script
If no unforeseen errors occurred, your rails app will be up and running in
production mode. Of course, $HOME/webapps/$APP_NAME must contain a
valid app for this to be true, even if it's just a skeleton. The working
default configuration sets up two thin instances listening on unix sockets
(mongrel does not have this capability) with nginx as the fair load balancing
reverse proxy. Monit watches nginx and the thin servers. A crontab entry
ensures that your setup springs back to life when the server has to reboot.
There are a couple of optional things you should do:
- Inspect the nginx and monit conf files to learn how they work. Modify them as you like.
- Generate ssl certificates and create an nginx https vhost following my example file if you have a dedicated IP address for https traffic.
Feedback
Please leave a comment!
