Saturday, September 3, 2011

Installing Zen CMS on Ubuntu (11.04)

I stumbled upon a new CMS based on Ruby/Ramaze. It is called Zen (http://zen-cms.com/). Since I have recently switched to Nginx/Unicorn Web environment and found that Ramaze works without any hick up in that environment, I decided to check it out. The following is how I installed it.

1. Resources.
Zen • The Modular CMS: http://zen-cms.com/
Ramaze: http://ramaze.net/
Running a Rack app (Ramaze) with Nginx/Unicorn: http://socrateos.blogspot.com/search/label/unicorn

2. Requirements.
Ruby 1.9.2 (MRI) - This is my default ruby.
Ramaze 2011.01.30 - I recently installed on my Ubuntu
A SQL database supported by Sequel - I am using PostgeSQL.
A Rack server (Thin, Unicorn or Mongrel) - I am using Unicorn.
Libraries required for Nokogiri: libxml2, libxml2-dev, libxslt-dev (libxslt1-dev was one that I found and installed, using Synaptic)

3. Installation.
$ sudo gem install zen
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.5.0
Successfully installed loofah-1.0.0
Successfully installed zen-0.2.8
3 gems installed
Installing ri documentation for nokogiri-1.5.0...
Installing ri documentation for loofah-1.0.0...
Installing ri documentation for zen-0.2.8...
Installing RDoc documentation for nokogiri-1.5.0...
Installing RDoc documentation for loofah-1.0.0...
Installing RDoc documentation for zen-0.2.8...

4. Create Zen Application
$ zen create app2
The application has been generated and saved in app2
$ cd app2/
$ ls
Rakefile  app.rb  config  config.ru  log  public  start.rb  task  theme

5. Setup Config.
The following is my settings for database.rb.
Zen.database = Sequel.connect(
  :adapter  => 'postgres',
  :host     => 'localhost',
  :username => 'socrateos',     # I have createdb, createrole rights
  :password => 'secret',
  :database => 'app2',
  :test     => true,
  :encoding => 'utf8',
  :logger   => Ramaze::Logger::RotatingInformer.new(
    __DIR__("../log/database/dev"), '%d-%m-%Y.log'
  )
)

# IMPORTANT, when running MySQL the engine should be set to InnoDB in order for
# foreign keys to work properly.
if Zen.database.adapter_scheme.to_s.include?('mysql')
  Sequel::MySQL.default_engine = 'InnoDB'
end

6. Failed to Rake DB:Migrate
I ran rake db:migrate. But it failed.
$ rake db:migrate --trace
W [2011-09-06 22:57:42 $2563]  WARN | : Failed to migrate the settings, make sure the database table is up to date
** Invoke db:migrate (first_time)
** Execute db:migrate
rake aborted!
PGError: ERROR:  ...
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:186:in `async_exec'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:186:in `block (2 levels) in execute'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/logging.rb:32:in `log_yield'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:186:in `block in execute'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:166:in `check_disconnect_errors'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:186:in `execute'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:256:in `block (2 levels) in execute'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/connection_pool/threaded.rb:71:in `hold'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/connecting.rb:226:in `synchronize'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:256:in `block in execute'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:277:in `check_database_errors'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/adapters/postgres.rb:254:in `execute'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/query.rb:71:in `execute_dui'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/query.rb:64:tin `execute_ddl'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/schema_methods.rb:372:in `create_table_from_generator'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/schema_methods.rb:97:in `create_table'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/extensions/migration.rb:629:in `schema_dataset'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/extensions/migration.rb:382:in `initialize'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/extensions/migration.rb:542:in `initialize'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/extensions/migration.rb:333:in `new'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/extensions/migration.rb:333:in `run'
/var/lib/gems/1.9.1/gems/zen-0.2.8/lib/zen/task/db.rake:28:in `block (4 levels) in '
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/query.rb:231:in `_transaction'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/query.rb:210:in `block in transaction'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/connection_pool/threaded.rb:84:in `hold'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/connecting.rb:226:in `synchronize'
/var/lib/gems/1.9.1/gems/sequel-3.26.0/lib/sequel/database/query.rb:208:in `transaction'
/var/lib/gems/1.9.1/gems/zen-0.2.8/lib/zen/task/db.rake:27:in `block (3 levels) in '
/var/lib/gems/1.9.1/gems/zen-0.2.8/lib/zen/task/db.rake:12:in `each'
/var/lib/gems/1.9.1/gems/zen-0.2.8/lib/zen/task/db.rake:12:in `block (2 levels) in '
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/var/lib/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in `'
/var/lib/gems/1.9.1/bin/rake:19:in `load'
/var/lib/gems/1.9.1/bin/rake:19:in `
' Tasks: TOP => db:migrate

1 comment:

  1. Strange for the Rake task to fail considering the Ramaze website also runs on Zen in combination with PostgreSQL. If you keep getting the error please report the issue on the bugtracker and I might be able to fix it :) https://github.com/zen-cms/Zen-Core/issues

    ReplyDelete