until nil {

Typo Blog on Dreamhost

17 Sep 2008

( Update! 2010-08-20 ). This blog is not powered by Typo anymore, while Typo has since evolved for the better, I choose now to work with statically generated html with the help of Jekyll. I leave this post here anyway, for those who might need it for references.

Typo, is a blogging system built with Ruby on Rails. I found this gem at a moment where I was thinking about building my own blog engine, and as it turned out, I liked it enough to use it to build this blog.

The overall Typo on Dreamhost installation is pretty straightforward. Dreamhost does a very good job at running Rails web application, mostly since the arrival of mod_passenger, the Apache module for running Ruby web applications. Think about it, from all web application languages you can run on Dreamhost, only Ruby has its own module for running on the web server. Everything else gets to run on CGI or Fast-CGI (yes, even PHP run as CGI on Dreamhost as on many other shared hosting, mainly for security purposes) giving Ruby a noticeable performance advantage. For this reason I expect to see a rise in the number of Ruby CMS, which are almost inexistent at this point compared to the plethora of PHP CMS out there. Also in the favour of this Ruby uprise, we could mention the sexyness of the language and the ease of development of the Rails framework as well as other Ruby frameworks.

One thing to keep in mind when running Ruby webapps on Dreamhost under Passenger, is that you don't have acces to the Apache .conf file. This is really to protect you from messing with critical web server settings, a subject you probably don't want to delve into considering the amount of possibility/flexibility/complexity it offers, especially if you want some free time to blog on your own afterward. This lack of access to the .conf file won't stop you from running a Ruby blog on Dreamhost though, will it? It could... the main consequence being that the Ruby environment (Ruby and its gems) that Passenger will use for serving your apps is not configurable. (Goshh!!) But, there is a but! You can still install your own Ruby environment under your own Dreamhost user account, some generator gems will be usefull right away, like the Typo gem, which creates the code to run the app and then let Passenger serve is as a normal Ruby webapp, and for most of the other gems there is a neat packaging gem, called gemsonrails, that allows to pack gems inside your Rails apps with no more external-custom-installed gem dependencies left.

Preparation:

First, you must configure your Dreamhost user environment to allow local installations to happen. You will do this by setting a couple of environment variables to point to a local install path. I recommend doing all these operations using SSH/SFTP for security considerations, but you may also choose to use telnet/ftp as it is somewhat easier to setup and in most occasions faster.

Start by creating directories for your installation on top of your user's home folder:

cd $HOME
mkdir .gem bin include lib src

Edit .bash_profile, adding this to the end of the file:

. .bashrc

Then edit .bashrc, putting those lines in it:

export PATH="$HOME/bin:$HOME/.gems/bin:$PATH"
export RUBYLIB="$HOME/lib:$RUBYLIB"
export GEM_HOME="$HOME/.gem"
export GEM_PATH="/usr/lib/ruby/gems/1.8:$GEM_HOME"
alias gem="nice -n19 ~/bin/gem"

Then comes the installations:

Proceed to the download the sources for Ruby and Rubygems, place them inside the src directory you created earlier in this tutorial. I choosed Ruby Enterprise Edition from Phusion, the creators of mod_passenger, mainly because of its ease of installation and in hope I could benefit from its improved memory management (garbage collection), but unfotunately at this point since we cannot modify the Apache .conf file we are stuck with the Dreamhost installed Ruby... but we will be ready for the day we get that configuration option!

You can download Ruby from: www.rubyenterpriseedition.com/

And Rubygem from: http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz

The Rubygem and Ruby installations goes as follow:

cd ~/src
tar xzvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
ruby setup.rb --prefix=$HOME

cd ~/src
tar xzvf ruby-enterprise-X.X.X.tar.gz
./ruby-enterprise-X.X.X/installer

When asked by the Ruby Enterprise installer where the installation should take place, answer with the full path to your user home directory. And by fullpath I don't only mean /home/YOURUSERNAME/, what I really mean is something like /home/.HIDDENFOLDERNAME/YOURUSERNAME/ . If you don't know that path, try connecting to your users directory with a SFTP client and the information will leak for you somewhere in there.

If you also choosed to install Ruby Enterprise Edition , then you will already have Rails and friends installed, if not then go for it, install them! So the last thing left to install is the Typo gem itself, and that is an easy one:

gem install typo

and thats all!
To get started with Typo refer to typosphere's documentation:
http://typosphere.org/wiki/typo

wait! wait! wait!

One last detail... If you follow the typosphere documentation exactly you'll get into troubles with the Dreamhost Police, because the installer defaults to using Mongrel... and starts it automatically at the end of the installation process, which goes against the host policy on permanently running processes. So don't forget to include a "web-server=external" in your install options... and if its already too late... they usually let you correct your mistake without sending you to the Dreamhost Jail, so you can use the "config" typo terminal command to finally set your options properly.

for more info on Typo's options visit:
http://scottstuff.net/blog/articles/2006/07/23/typo-installer

blog comments powered by Disqus

}

Older Posts... Blog powered by Jekyll.
Built using Liquid, RedCloth, Pygments and Blueprint.

Copyright © 2008-2010 Louis-Philippe Perron