Very Usefull links:
Problem: Deploy a rails app written in debian lenny (rails 2.1) into this stable web-server (etch)
Solution: Put everything inside your lib/vendor rails application (search google about it and good luck).
but if you need for some reason a per-server installation insted of a per-application try this:
- Install “ruby1.8” with all the suggested optional packages
- Install “ruby1.8-dev libsqlite3-dev libopenssl-ruby build-essential”
- Download GEM (rubygems-1.2.0.tgz) from http://rubyforge.org/
- add your user to group staff and re-login, now you can write inside /usr/local.
- edit setup.rb (GEM) and change the line below to prevent gem from copy rails bin into /usr/bin, I think there is some better way to do this
if prefix.empty? lib_dir = Gem::ConfigMap[site_or_vendor] - bin_dir = Gem::ConfigMap[:bindir] + bin_dir = '/usr/local/bin' else
and it should install gem inside your /usr/local dir.
Export some variables
export GEM_HOME=/usr/local/lib/ruby/gems export PATH=$PATH:/usr/local/lib/ruby/gems/bin
gem1.8 install -v=2.1.0 rails gem1.8 install sqlite3-ruby gem1.8 install mongrel gem1.8 install mongrel_cluster
copy your application and shoot script/server, it should work starting a mongrel.
mongrel_rails cluster::configure -e production -c /var/yourhomesapps -a 127.0.0.1 --user www-data --group www-data
and as ROOT
mkdir /etc/mongrel_cluster cp /usr/local/lib/ruby/gems/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/ chmod +x /etc/init.d/mongrel_cluster cd /etc/mongrel_cluster ln -s /var/yourhomesapps/config/mongrel_cluster.yml yourapps.yml
edit “/etc/init.d/mongrel_cluster” and add
- PID_DIR=/var/run/mongrel_cluster - USER=mongrel + PID_DIR=/tmp/mongrel_cluster + USER=www-data RETVAL=0 + export PATH=$PATH:/usr/local/lib/ruby/gems/bin + export GEM_HOME=/usr/local/lib/ruby/gems # Gracefully exit if the controller is missing. which mongrel_cluster_ctl >/dev/null || exit 0
and fire a
update-rc.d mongrel_cluster defaults 90
Ok you are ready to proxy from your web-server to mongrel running on ports 3000 and 3001.
ps: if your apps in not a root apps, ex: http://mywebsite/apps/myapps, then you have to use –prefix parameter when create mongrel_cluster.yml, or for ex. your images will be at /images instead of /apps/myapps/images.
- logs grow into your apps/log directory without control
- PIDs are stored into your app dir which is not good.