Setting up Fat Free CRM on Webfaction

Fat Free CRM is a lightweight Ruby on Rails application, which is very similar to the Highrise application by 37 Signals. These days I am trying to reduce my dependency on SAAS providers by hosting applications I use on a managed service. Why I am following this particular approach is beyond the scope of this post, but I could not find any instructions online that would get Fat Free CRM running on my hosting provider – Webfaction.

Before you start, I should warn you that I know precious little about Rails other than my usage of Redmine and FatFree. If you were to ask me to help you with any issue you’d face following these instructions, the odds are that I would not be able to help you at all. So proceed at your own risk.

1. Set up a Ruby on Rails application as detailed here.

2. SSH into your host and change to your webapp’s directory
cd ~/webapps/your_webapp_name/

3. Export the environment variables as specified in the Webfaction guide:
export PATH=$PWD/bin:$PATH
export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib

4. Check if the correct Ruby and Gem versions are being called. It should use the app’s versions and not the ones installed by default on the server.
which ruby
which gem

5. Install some gems.

gem install bundler passenger activesupport mysql2 activerecord-mysql2-adapter

6. Get a copy of FatFreeCRM from the Git repo.

git clone fatfree

7. Create a new database for the app.

8. Create the database.yml file and change the connection details in it.

cd fatfree/
cp config/database.mysql.yml config/database.yml
vi config/database.yml

9. Edit the Gemfile to uncomment the mysql2 adapter.

vi Gemfile

10. Check the bundler and rake versions, just to be doubly sure.

which bundle
which rake

11. Run db:migrate and db:set-up. 

RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake ffcrm:setup

12. Change to config.assets.compile = true in production.rb

vi config/environments/production.rb

13. Edit nginx configuration to point to ‘fatfree’ from ‘hello_world’

vi ../nginx/conf/nginx.conf

14. Restart nginx