mahiwaga

I'm not really all that mysterious

migrating from wordpress to typo 4.1.1 (trunk) on dreamhost

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`{: .block} (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.

initially published online on:
page regenerated on: