Upgrading to Typo 5.3 (on Dreamhost) 3

Posted by Peter Burkholder Wed, 22 Apr 2009 02:20:00 GMT

Upgrading from Typo 4.0.3 to Typo 5.3 on Dreamhost Rail

I’ve been slacking lately on my blogging, which is a shame because I have much to write about. So much going on, no time to write about it. To help rectify that, I intend to start devoting Tuesday evenings to technology blogging, and to start things off, let’s upgrade this dumpy old Typo 4.0.3 to shiny new Typo 5.3.

I’m on Dreamhost, and they suck, but not bad enough for me to pick up and go elsewhere, so I guess that actually counts as good service. So here are one set of correct steps to upgrade a Typo 4.X installation to Typo 5.3. These are based on the Upgrading to Typo5.3 instructions, but differ at a few points for Dreamhost specifics, and to accomodate my own mistakes.

  • login to the Typo web interface and uninstall all your sidebars (see note below)
  • use mysqldump to dump the mysql database
    mysqldump -u typo -p -h mysql.typo.pburkholder.com typo > ~/backup/typo.mysql
  • use tar to copy the typo installation

tar -czf backup/typo.4.0.3.tgz ./typo.pburkholder.com/

  • install the ‘typo’ gem. I’ve been using ~/.rubygems as my local gem install, so export GEM_PATH=/usr/lib/ruby/gems:/home/pburkholder/.rubygems
    gem install -i ~/.rubygems typo
  • now do the install:

~/.rubygems/bin/typo install ~/typo.pburkholder.com

  • move some of my old files over (the upgrade instructions suggest copying over old themes, don’t)

mkdir ~/typo.pburkholder.com/public/files/
cp typo4.pburkholder.com/public/files/* typo.pburkholder.com/public/files/
cp typo4.pburkholder.com/config/database.yml typo.pburkholder.com/config/database.yml

  • run the database migration cd ~/typo.pburkholder.com
    rake RAILS_ENV=production db:migrate
    rake gems:refresh_specs
    (The last step may not be necessary, but worked for me)
  • your old theme won’t work. Period. Simplest solution I came up with was to symlink a 5.3 theme to my old theme name. E.g., I had ‘azure’ as my theme, and ‘scribbish’ came with 5.3, so:

cd ~/typo.pburkholder.com/themes; ln -s scribbish azure

  • start a single instance on port 3000 and see how things are on http://typo.pburkholder.com:3000

script/server -e production (Ctrl-C to kill)

  • set up Passenger. I had been running the blog using FastCGI back before Dreamhost had any real Rails support. Now they support Passenger, which is promising. I had been running Typo using FastCGI suppor and an .htaccess file that called dispatcher.fcgi, and it was a dog. So..
  • Go have fun!!

What if I skipped step 1?

I misread the upgrade instructions, and moved the sidebar code instead of ‘removing’ them from the web UI. My new Typo instance complained bitterly about missing sidebars. To remove the sidebars manually is just a matter of connecting the production MySQL database and seeing what’s in the sidebars, then removing them:


select * from sidebars\G
delete from sidebars where id>1;

Now I need to replace my old sidebar links, such as:

*My (out-of-date) resume *LinkedIn Profile

Installing Rails on Mac OS X with MacPort 4

Posted by Peter Burkholder Fri, 17 Nov 2006 21:08:00 GMT

Yesterday I installed Ruby on Rails on my new(-ish) Intel MacBook. Last time around I built with a combination of Fink packages and hand-built applications following this posting at Hivelogic

This time around I’ve been using MacPorts, and it’s making my life much easier. Evan Weaver got me started with his post on building ruby, rails and associated pieces, but enough has changed changed since June 26 to merit my own updated take on the process.

Getting started

As Evan notes, “First, install the Apple Xcode tools from your OS X installation disc”. Please do so.

Next, install a recent version of “MacPorts” (what used to be known as DarwinPorts) from their Subversion respository. Installing from a .dmg file is easiest, then you can let MacPorts upgrade itself later on. As of this writing, Ports 1.3.2 is out, but disk images are only available for 1.3.1, e.g. at DarwinPorts-1.3.1-10.4.dmg

Next, you’ll want to update your executable path so the Ports installations in /opt/local are found before your Apple binaries. You should edit both /etc/profile and your ~/.bashrc (or equivalent if you’re using some other shell. Your path should end up looking something like this:

PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin" 

Install the ports

Now open a terminal (/Applications/Utilities/Terminal) and run the following:

sudo port -d selfupdate 
sudo port install lighttpd +ssl 
sudo port install rb-rubygems
sudo port install rb-fcgi
sudo port install mysql4 +server

Set up MySQL

You’ll also need to get mysql4 set up with these commands:

# set up the mysql database:
sudo -u mysql mysql_install_db
# start the server:
sudo /opt/local/bin/mysqld_safe --user=mysql
# set the root password (picking your own password, of course)
/opt/local/bin/mysqladmin -u root password newpassword

If you want Launcher to start MySQL automatically on reboot, you can run the following:


sudo launchclt load -w  \
  /Library/LaunchDaemons/org.macports.mysql4.plist
# stop the server
sudo launchctl stop org.macports.mysql4
# start the server
sudo launchctl start org.macports.mysql4

Install the gems

Running gems with the ‘-y’ option automatically takes care of prerequisites

sudo gem install -y rails
sudo gem install -y capistrano

Test!

First, are you hitting the right version of Ruby? ruby --version should return something like ruby 1.8.5 (2006-08-25) [i686-darwin8.8.1] not this: ruby 1.8.2 (2004-12-25) [universal-darwin8.0]

Next, can you build a Rails application with


cd ~/tmp
rails widgetapp

Okay? Good. Now let’s cd widgetapp and put the database through it’s paces. Save the following code as test_rails_db.sh (or download it here)


#!/bin/sh

echo -n "Enter MySQL root password: " 
read PASSWD

mysqladmin -u root -p$PASSWD create widgetapp_development

cat >db/create.sql <<EOF
DROP table if exists widgets;

CREATE table widgets (
    id  int not null    auto_increment,
    name    varchar(40)  not null,
    description   varchar(100)   not null,
    primary key (id)
    );

INSERT INTO widgets (name, description) VALUES ("Tool", "Useful item");
INSERT INTO widgets (name, description) VALUES ("Food", "Tasty stuff");

EOF

mysql -u root -p$PASSWD  widgetapp_development < db/create.sql

mv config/database.yml config/database.yml.dist

cat >config/database.yml <<EOF 

development:
  adapter: mysql
  database: widgetapp_development
  username: root
  password: $PASSWD
  socket: /opt/local/var/run/mysqld/mysqld.sock

EOF

and run sh ./test_rails_db.sh. Enter your password when prompted.

Now the proof is in the pudding. If the following run s while you’re in your widgetapp rails directory, you’re golden:


script/generate scaffold Widget
script/server

Now browse to http://0.0.0.0:3000/widgets/list and you should utter a little gasp of joy.