Getting a Rails blog up and running

by Herb on 4 June 2007

Compared to my previous weblogs (WordPress, Drupal and the like), getting a rails blog going is much more involved, especially on a shared host. So involved in fact, it’s perfectly fitting for the first post of this new development blog. I read a variety of blog posts out there, but there was still additional issues on the Cpanel box I’m using. On a positive note, this did teach me a thing or two about deploying Rails apps on Apache.


Get the latest typo revision:

# cd ~
# svn co http://svn.typosphere.org/typo/trunk typo

Link typo to your site:

# cd public_html
# ln -s ../typo/public blog

Time to make some changes to the Typo package so it works with the shared host. You have to configure the database, migrate/import the database structure, and patch a few files. Start by creating a new mysql database and user, then configure typo.

Edit config/database.yml:

login: &login
  adapter: mysql
  host: localhost
  username: yournewuser
  password: yournewpass
 
 
development:
  database: yournewdb
  < <: *login
 
test:
  database: typo_tests
  <<: *login
 
production:
  database: yournewdb
  <<: *login

Importing tables is easy with Rake:

# rake db:migrate
or
# rake migrate

If there are any errors at this point, check the db config and make sure to drop any existing tables.

The default dispatcher configuration is broken, and will fill up your apache error log in no time. Make the following changes, restart your webserver and have fun.

Enable Production Mode in config/environment.rb:

ENV['RAILS_ENV'] = 'production'

Update ruby paths (to include full path to ruby, on most shared hosts this is /usr/local/bin/ruby) in public/dispatch.fcgi public/dispatch.rb:

#!/usr/bin/env /usr/local/bin/ruby
and
#!/usr/local/bin/ruby

It's likley that the webserver won't have proper write access to the tmp/ and log/. To make this easy make both of them world-writeable.

# chmod 777 tmp/ log/

I was lucky to be able to restart apache at will, I am interested in how others get around it without that privilege. Good Luck Typo fans!

Leave a Comment

Previous post:

Next post: