How to Install Typo at A2hosting

Posted by – September 24, 2008

I’m new at A2hosting, and just went through almost a weeks worth of back and forth with their tech support folks. Being that their wiki on installing a Typo blog is out of date – I thought I’d make this my first post on my new blog.

Prep

The first thing you’ll want to do is submit a ticket to have Rails 2.0.2 installed. The default Rails 2.1.1 will not work with Typo at this time. There is an experimental branch of Typo to support Rails 2.1.1, but being new to RoR – I didn’t want to go that route. Also, if you haven’t already – you might want to ask them to install wget for you, as it’s what I use to download stuff from the command line. You can use curl if you are comfortable with it also.

While A2hosting is working on getting Rails ready to go, you can use cPanel to setup your MySQL and ruby app.

Set up your database

From the cPanel front page:
  1. Click ‘MySQL Databases’
  2. Name your new database ‘typo’ and hit ‘Create Database’ (Your username will be prefixed to the database name, i.e. ‘johndoe_typo’)
  3. Scroll down the page a bit and add a new user called ‘typo’ and set a password(write this down) – hit ‘Create User’ (Your username will be prefixed to the database name, i.e. ‘johndoe_typo’)
  4. Scroll back down and add the user to the database – select the user and database from the dropdowns and hit ‘Add’, on the resulting page, check the “ALL PRIVILEGES” box and hit ‘Make Changes’

Create your Rails app

To be honest, I’m not totally sure this step is necessary. When working with A2hosting tech support, they claimed that their rails app showed up automagically when they extracted the typo archive into their web directory, which is the next step, but this didn’t happen for me, so here’s what I did instead:

You will need an empty directory to put your app. I’d suggest

[[code]]czoxNjpcIm1rZGlyIH4vd3d3L3R5cG9cIjt7WyYqJl19[[/code]]

Then head back to the cPanel frontpage and look for ‘Ruby on Rails’

  • app name = typo
  • path = public_html/typo (www is a symlink to public_html)
  • load on boot = checked
  • environment = production (you could go with development, and should switch it if you have issues – but for now just go with production)
  • Hit ‘Create’
  • Create the rewrite you want(This is necessary if you want to use a rails app, but you can redirect the root directory of your domain like I’ve done)

Now you’re going to say I’m crazy – but go back to your shell and blow away the directory we created earlier

[[code]]czoxNzpcInJtIC1yZiB+L3d3dy90eXBvXCI7e1smKiZdfQ==[[/code]]

Like I said, this was really just to get the typo app listed in cPanel so that we can start/stop it, create a re-write, and toggle the other settings. We are going to recreate the typo directory but populate it with the actual Typo code in the next step.

Download Typo

After Rails 2.0.2 is installed, you can go ahead and download Typo. Connect to your server via ssh and then do the following:

Configure the database connection

First things first, rename database.yml.example to database.yml:

[[code]]czo2NzpcIgptdiB+L3d3dy90eXBvL2NvbmZpZy9kYXRhYmFzZS55bWwuZXhhbXBsZSB+L3d3dy90eXBvL2RhdGFiYXNlLnltbApcIjt7WyYqJl19[[/code]]

Now use your favorite text editor to make database.yml look like this(use the username/password and database names you created earlier):

login: &login
  adapter: mysql
  host: localhost
  username: yourusername_typo
  password: yourpassword
  database: yourusername_typo

development:
  database: yourusername_typo
  <<: *login

test:
  database: yourusername_typo
  <<: *login

production:
  database: yourusername_typo
  <<: *login

Strictly speaking, you’re all set – but there are some issues that I had to work though before Typo started working for me.

Fixes

A couple issues came up at this point for me. A2hosting support was kind enough to provide one of these, but after some chiding from them – I was forced to look up the other myself ;)

  1. Open up ~/www/typo/config/boot.rb and browse down to line 29. The line begins with ‘require_gem’ and needs to be replaced with just ‘gem’. Apparently this is depreciated code, and I suspect it has at least something to do with the next fix.
  2. Open up ~/www/typo/app/models/article.rb and pop down to line 296 and add:

[[code]]czoxMzI6XCIKCiNBZGRlZCBwZXIgaHR0cDovL3d3dy50eXBvc3BoZXJlLm9yZy9pc3N1ZXMvc2hvdy8xMjY0IHRvIGNvcnJlY3QgZXJ7WyYqJl19cm9yIHVwb24gbWFuYWdpbmcgY29udGVudAogIGRlZiBwdWJsaXNoZWQ/CiAgICBwdWJsaXNoZWQKICBlbmQKXCI7e1smKiZdfQ==[[/code]]

Both of these issues are probably caused by A2hosting using Rails 1.8.7 and Typo supporting 1.8.6 – but they seem to be workable this way. I’d be curious if anyone else tries downgrading to 1.8.6 and skipping these 2 steps.

Start yer app!

Go back into cPanel, Ruby on Rails section and hit ‘Run’ for your Typo app. After the confirmation screen, use the ‘Go back’ link and make sure it says “Running” and not “Not running”. If it’s going – direct your browser to whatever url you designated in your rewrite(or click the ‘URL’ link in the app table). There should be/might/will be a delay while the Typo database structure is set up – then you’ll create your first user.

If your app is not running at this point – please do leave a comment. It may be that I’ve left something out.

The rest is up to you!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">