Create your blog with TYPO

General Information

Typo is a Ruby on Rails application and in this article you can find how to install Typo v. 4.1.1 easily in a few steps on FreeBSD 6/7.

Requirement

The only requirement is to have already installed in your machine Ruby, Ruby on rails and some other required gems by Typo (mongrel, mysql, mysql, rcov, rspec, xmpp4r, flexmock, hoe, ruby-debug and ruby-debug-base). Follows my local gem complete list with package name & version :

  1. *** LOCAL GEMS ***
  2. actionmailer (1.3.6)
  3. actionpack (1.13.6)
  4. actionwebservice (1.2.6)
  5. activerecord (1.15.6)
  6. activeresource (2.1.0)
  7. activesupport (1.4.4)
  8. cgi_multipart_eof_fix (2.5.0)
  9. cmdparse (2.0.2)
  10. columnize (0.1)
  11. daemons (1.0.10)
  12. ezcrypto (0.7)
  13. fastercsv (1.2.3)
  14. fastthread (1.0.1)
  15. flexmock (0.8.2)
  16. gem_plugin (0.2.3)
  17. highline (1.4.0)
  18. hoe (1.5.3)
  19. linecache (0.43)
  20. mime-types (1.15)
  21. mini_magick (1.2.3)
  22. mongrel (1.1.5)
  23. mongrel_cluster (1.0.5)
  24. mysql (2.7)
  25. rails (1.2.6)
  26. rake (0.8.1)
  27. rcov (0.8.1.2.0)
  28. rspec (1.1.4)
  29. ruby-debug (0.10.1)
  30. ruby-debug-base (0.10.1)
  31. rubyforge (1.0.0)
  32. rubygems-update (1.1.1)
  33. sources (0.0.2)
  34. xmpp4r (0.3.2)

As you can see I use rails v. 1.2.6 and this is main reason that I use the 4.1.1 version of Typo (the last Typo version is 5.0.3 and is fully documented on the official site of Typo), but you’ll need RoR 2.x version.

Installation

Let’s start building our Typo-4.1.1 blog:

Download typo-4.1.1.tgz (use fetch or wget or via ftp)

$ fetch http://rubyforge.org/frs/download.php/20466/typo-4.1.1.tgz

Extract it in your rails work directory

$ cd my-rails-work-dir
$ tar -zxvf typo-4.1.1.tgz

If you take a look no at your rails work directory you’ll see that typo-4.1.1 rails app directory is created. Before proceeding I suggest you to rename your blog in order to add later more blogs in the same rails work dir.

$ mv typo-4.1.1 MyWonderfulBlog

That’s it. Now i’m ready to configure in a few step my new blog. All work will be done inside MyWonderfulBlog directory.

Configuration

Go in ~/MyWonderfulBlog/config/ and copy database.yml.example as database.yml

$ cp database.yml.example database.yml

Note: The application is already developed so you can choose to work directly in production environment. Truely, there is no need to select development, but if you do so, there is always an easy way to switch from development to production environment. If you prefer to work in development environment just replace prod with dev in the following steps.

Let’s check database.yml with our favorite editor. In production environment you’ll only need to leave the production section. I’ll change the database names – I’ll use more than one blogs in the same system – so I don’t want my databases to have the same name. I’ll use a safe mysql username & password as the following:

production:
  adapter: mysql
  encoding: utf8
  database: wonderfulblog_prod
  username: safesql
  password: mysqlko9
  socket: /tmp/mysql.sock

Now It’s time to create my database

$ mysqladmin -u root -p create wonderfulblog_prod

…and it’s done.

Grant privileges at the db user: safesql for the production database wonderfulblog_prod

$ mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is xxx
Server version: 5.0.51a FreeBSD port: mysql-server-5.0.51a

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> grant all privileges on wonderfulblog_prod.* to 'safesql'@'localhost'
identified by 'mysqlko9';
Query OK, 0 rows affected (0.09 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)

mysql> q
Bye

Populate your database with the typo app data. The right way to act is with the magic “rake db:migrate” command, but with the version 4.1.1 this doesn’t work. Use instead:

$ rake migrate RAILS_ENV='production'

Note: In development environment use simply “rake migrate”

Rake will extract all necessary items in your database.

That’s all! Now Typo is ready to run! I use Mongrel to fire up my rails apps, because Mongrel it’s easy to setup, run & control. Once Mongrel is set up with a single command I get in production my application (the typo in this case, but similarly works with any app). You have only to select a port (default 3000, I use 8921 in this example), use the flag -d (daemonized – runs in background) and specify the production environment (if you don’t use the flag -e, Typo select development environment by default).

$ mongrel_rails start -d -p 8921  -e production

Open your browser and point to http://localhost:8921/admin. It’s important to put a username & password in order to safe your blog.

After that you can access the administration interface ( http://localhost:8921/admin ), and view the results at http://localhost:8921.

Speak Your Mind

*