Fix the Apache trailing slash problem

Posted by Chris Sun, 17 Jun 2007 10:48:00 GMT

After a lot of stuffing about I finally found a solution to the problem that I was having with the URL for this blog.

The basic problem was that the link http://www.drinkingbird.net/blog (without the trailing slash) was being rejected with a 400 Bad Request error.

I spent ages trying to get this to work with awkward rewrite rules in the parent directory, when I should have been looking in the public directory of the rails app. The solution is well enough explained over at LavaFactory.

I just made one small refinement, which is to change:

RewriteRule .*/blog/(.*) http://www.drinkingbird.net/blog/$1 [L,R]

to

RewriteRule (.*)/blog/(.*) $1/blog/$2

to satisfy my relentless desire to avoid configuration tied to a particular domain.

Posted in ,  | no comments

Typo on Site5

Posted by Chris Sun, 10 Jun 2007 11:51:00 GMT

I thought I’d post a quick summary on what I went through to get Typo up and running on Site5, since it’s a bit more tricky now that the SiteAdmin interface no longer contains an automatic install script.

I decided to go the gem route on this, so that’s the only way I’m going to talk about. If you want to install from SVN trunk, you’re on your own.

First, you’ll want to set up your account with a local gem installation directory, as detailed in this forum thread.

Then, ssh into your account (if you’re not still there), and type:

gem install typo

There’s a good chance this will fail the first time, with an error on attempting to install the sqlite3-ruby gem. This can be solved by opening a ticket with Site5’s support, and asking to have the sqlite-devel package installed on your server, then trying again.

Once the gem is installed, you just need to run

typo <installation directory>
then manually kill the mongrel process it spaws immediately after installation (I’d lay money on site5’s servers doing this automatically if you don’t anyway). From here, it’s all fairly easy: Edit the environment.rb file in typo’s config directory, and uncomment the line:
ENV['RAILS_ENV'] = 'production'

and add the line:

ENV['GEM_PATH'] = '/home/<your_username>/<path_to_gems>:/usr/lib/ruby/gems/1.8'

Create the file public/.htaccess in the typo directory as:

# General Apache options
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 /500.html # You may want to edit this file

Setup a mysql database for the blog’s production db, and configure it in config/database.yml. Example config:

production:
  adapter: mysql
  database: username_blog
  username: username_blog
  password: secret
  host: localhost

Then run

rake db:migrate RAILS_ENV=production

to load the schema.

If you installed your blog anywhere other than under your public_html directory, you’ll need to create a symlink to the blog, e.g.

ln -s /path/to/typo/public public_html/blog

Hopefully this ends up helping someone. If not, well at least it gave me an excuse to get to grips with some of typo’s editing syntax. If I’ve missed anything, please bitch at me, so I can fix it.

Posted in ,  | 2 comments