dendritic arborization • I like that phrase

disordered thought processes

hidden in the seeming chaos is beautiful, elegant order—at least, I hope that's true.

giving up on rails on dreamhost

posted on January 22nd, 2008

Since I’m only averaging about 500 hits per day, shared hosting should theoretically be sufficient for my purposes. Alas, Mephisto continually dies on Dreamhost, and since I couldn’t get my kludgery to work (mostly because I can’t seem to install the mysql gem on my local setup), I gave up completely and found a host that actually supports Rails.

Migrating was not exactly pain free, but hopefully my domain name will propagate completely by tomorrow or the next day. I’m not sure why Mephisto started failing to run on Dreamhost. My logs were not at all helpful.

Whatever. Hopefully, I’ll get a decent job starting this summer, and the webhosting fees will stop feeling so significant. Either that, or I’ve got to start using Adsense. And maybe I’ll end up migrating all my sites away from Dreamhost at this rate.

fubar. snafu.

posted on August 15th, 2007

So apparently it was all Dreamhost’s fault. Both Mephisto and Movable Type are working at reasonable speeds. I still stand by the notion that Dreamhost really can’t handle Ruby on Rails very well. I’m looking into switching to (or at least adding on) a different shared host. Site5 looks promising.

I’m not blaming Dreamhost for the connectivity snafu today. It is, after all, shared hosting, and I’m not exactly running anything mission critical here. (And I luckily had the foresight to have Google handle my e-mail. Privacy, smivacy, the NSA is looking at all this crap anyway.) But I do want to play around with Ruby on Rails some more, and Dreamhost just doesn’t seem like the place to go in that regard.

I do, however, blame the spammers. I’m certain that they’re responsible for the network slowness. I’m pretty sure it wasn’t just Dreamhost that was affected. A lot of other sites seemed to respond sluggishly this morning as well. My apache log files are saturated with apparent attempts to post spam comments and spam trackbacks.

I wish they could relax the law so that spammers were fair prey for vigilante justice. I would so take an aluminum bat to the head of a spammer. Seriously. I’m not usually a violent man, but these scum ruin the Internet for everyone.

I found all of this rather confusing, since I’m pretty sure I downloaded the same version of Mephisto to my local machine as well as to my Dreamhost account. But I got things running on my local machine with no problem, but had to struggle for a couple of days to get it to work on Dreamhost (with Ruby 1.8.5 and Rails 1.2.3 as of this writing.)

Now Mephisto 0.7.3 works fine out of the box on Dreamhost, something which I myself have confirmed, but unfortunately it’s missing a few choice features found in trunk (specifically next_article and previous_article methods which are available to Liquid) but the average user may not need these things. (As of this writing, I still haven’t implemented chronologic navigation, something which I’ve been extremely fond of because it makes it unobtrusive to read my blog from beginning to end. Narcissistic much?) So follow these instructions and you should be good to go in no time.

Now if you’re a tad more adventurous, you can try the following instructions on installing trunk (which as of this writing is in revision 2936. As to whether newer revisions will work is anybody’s guess.)

Use svn to download the code:

svn checkout http://svn.techno-weenie.net/projects/mephisto/trunk [destination directory]

Out of the box, the code seems to choke on a call to a Liquid method. This was seemingly fixed by updating the Liquid plugin:

./script/plugin install http://liquid-markup.googlecode.com/svn/trunk

(Note: script/plugin is relative to the directory you installed Mephisto into.) Liquid (trunk) is currently at revision 6. I’m not really sure if this might break something else entirely, but so far, so good.

After this, you can follow the same instructions for installing mephisto-stable.

Various little things I learned which may be of dubious benefit to others: 6d407a277e81c13e46c7419ca24e0369

Coming up: how I converted Wordpress categories to Mephisto tags.

This is just a quick outline of the steps I took, which I hope to fill in as time goes on.

This route is really circuitous, mostly because the migration script included with Typo is apparently very CPU/memory-intensive, and Dreamhost’s sentinel processes always ended up reaping it before it could even import a couple of blog posts. It also requires the installation of random pieces of software you probably won’t normally use on your local machine. Be forewarned.

NOTE: My desktop computer is a Mac Mini PowerPC G4 running at 1.25 GHz with 1 GB of RAM installed, running Mac OS X 10.4 Tiger. These instructions should be equivalent for an Intel-based Mac, and should be reasonably adaptable for Linux, BSD, or other UNIX/UNIX-like systems. Unfortunately, I haven’t run Windows since 1999, so I can’t really help you there.

  1. Export your Wordpress database using whatever method is most comfortable to you. I used myPHPadmin which is available by default on Dreamhost. Transfer the resulting flatfile to your local machine.
  2. Make sure you have MySQL running on your local machine. Of interest, MySQL is installed by default in the Server version of Tiger, although turned off by default. It should be pretty easy to install MySQL on any respectable Linux distribution. On the Client version of Tiger, while you can build mysql using Fink or MacPorts, the easiest thing (read: the thing that involved the least amount of thinking and/or compiling) was to just download the binary distribution from mysql.com. The stable version as of this writing is 5.0.
  3. Install CocoaMySQL. Obviously, if you’re quite familiar with dealing with MySQL on the command-line, there’s no need to do this, but since I’m not, this was the easiest thing to do.
  4. Import your database from Dreamhost into your local copy of MySQL
  5. Make sure you have a functioning copy of Ruby installed. Tiger comes with an old version of Ruby installed, so I tried compiling the newest release with Fink. Unfortunately, there are still some issues with compiling Ruby using gcc 4. While it will build without problems, Ruby will segfault randomly when run. Since I didn’t really want to screw around with compiling with gcc 3.3 and making sure all the relevant dependencies would play nice, I ended up installing Locomotive, which lets you run Ruby on Rails applications in a sandboxed environment.
  6. Install Rails. Again, Locomotive will take care of this for you, but if you’re running Linux, or you manage to get ruby correctly compiled on Mac OS X, you can just install the gem like so: gem install rails --include-dependencies
  7. Make sure you have svn installed. Subversion, a version control system, is readily available on all respectable Linux distributions and can be compiled without incident on Mac OS X via Fink or MacPorts or even just from source.
  8. Download typo via svn. You can pretty much install Typo anywhere you like. Once you’re in the directory (folder) of your choice, type: svn checkout http://svn.typosphere.org/typo/trunk typo (see the Typo Trac for more info about grabbing the trunk versus the 4.1 branch.)
  9. Create a new database for use with Typo.
  10. Configure Typo to use the new database Edit config/database.yml (relative to the directory you downloaded Typo to) so that it’s pointing to your new database.
  11. Format the new database with Typo’s schema. I used rake db:migrate Other ways (not sure if this is up to date) are described on the Typo Trac. These should work just as well on your local machine as it does on Dreamhost’s servers.
  12. Run the Wordpress 2 → Typo 4 converter script. (If you’re using Locomotive, at this point you’ll need to create a new project and point it to where Typo is living, and start it.) Type db/converters/wordpress2.rb --help for help with the syntax with converter.
  13. Export the Typo database on your local machine.
  14. Create a new database on Dreamhost for Typo.
  15. Import the flatfile from your local machine into the database on Dreamhost.
  16. Install and configure Typo on Dreamhost exactly as above. From what I can tell, Dreamhost now has a current enough version of Ruby (1.8.5) and Rails (1.2.3) to run Typo properly, but if you must have the newest versions of everything, you can build it all in your home directory.

At this point, you should be able to point your browser to your site and create an admin account. All your Wordpress posts will be there, although the converter script turns all your entries and all your pictures into separate blog posts.

Right now, I’m running Typo out of the box without having to put in the hackery used to avoid getting 500 errors. Compared to a year ago when I tried Typo out, it feels a lot faster and more responsive, although it is still kind of slow. We’ll see how it goes.

One thing that I found irksome, and for which I couldn’t find an easy solution to on Google, is that Typo’s permalinks are formatted like so: http://domain.name/articles/yyyy/mm/dd/slug In contrast, Wordpress’s permalinks are http://domain.name/yyyy/mm/dd/slug. Personally, I feel that articles is unnecessarily crufty, but I couldn’t figure out an easy way to get rid of it. I couldn’t get Apache’s mod_rewrite to work with Typo either. So this is what I ended up having to do to at least keep my Wordpress permalinks alive. (Derived from WordPress to Typo Migration, Part II.)

In config/routes.rb, add this:

  map.connect ':year/:month/:day/:title',
      :controller => 'wordpress_url', :action => 'redirect',
      :requirements => {:year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/}
  

This will require you to create a new file in app/controllers/ called wordpressurlcontroller.rb

app/controllers/wordpressurlcontroller.rb contains the following:

  class WordpressUrlController < ApplicationController
     def redirect
        year = params[:year]
        month = params[:month]
        day = params[:day]
        title = params[:title]
        url = "/articles/#{year}/#{month}/#{day}/#{title}/"
        redirect_permanently url
     end
    def redirect_permanently url
      headers["Status"] = "301 Moved Permanently"
      redirect_to url
    end
 
    private :redirect_permanently
  end

Now, I’m a Ruby/Rails newbie, so if there is a cleaner way to do this, or if there is a way to get rid of articles from the permalink, suggestions would be appreciated.