Skip to content

How to Install CKAN on an Ubuntu 10.04 Vagrant Virtual Machine

wilhelmbot edited this page Apr 26, 2013 · 2 revisions

You can install CKAN in a virtual machine using Vagrant, a tool for managing virtual machines.

1. Install VirtualBox and Vagrant on your system, following the instructions on the Vagrant website.

2. Use vagrant to create an Ubuntu 10.04 virtual machine, boot it up, and ssh into it:

 host> vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
 host> mkdir my_vagrant_box
 host> cd my_vagrant_box
 host> vagrant init lucid32
 host> vagrant up
 host> vagrant ssh
 vagrant@lucid32:~$

3. Inside your virtual machine, install the latest Ubuntu updates and install PostgreSQL:

 vagrant@lucid32:~$ sudo aptitude update
 vagrant@lucid32:~$ sudo aptitude upgrade
 vagrant@lucid32:~$ sudo aptitude install postgresql

4. Create a postgresql database cluster and check that you can connect to postgresql and list your databases:

 vagrant@lucid32:~$ sudo pg_createcluster 8.4 main --start
 vagrant@lucid32:~$ sudo su
 vagrant@lucid32:~$ sudo -u postgres psql -l

You should see something like this:

                                   List of databases
    Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges   
 -----------+----------+----------+-------------+-------------+-----------------------
  postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
  template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                              : postgres=CTc/postgres
  template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                              : postgres=CTc/postgres
 (3 rows)

4b. If you get an initdb: encoding mismatch error from the pg_createcluster command, then you need to fix your virtual machine's broken locale settings (thanks, Crowd Interactive Tech Blog):

Edit the system bashrc file (sudo nano /etc/bash.bashrc), add these lines to the bottom of the file:

 # Add these lines to the bottom of the file:
 export LANGUAGE=en_US.UTF-8
 export LANG=en_US.UTF-8
 export LC_ALL=en_US.UTF-8

Save the file and exit your text editor, then do:

 vagrant@lucid32> sudo locale-gen en_US.UTF-8
 vagrant@lucid32> sudo dpkg-reconfigure locales

Then disconnect from your virtual machine (ctrl-d) and connect to it again (vagrant ssh). You should now be able to create the databse successfully.

5. Follow the Ubuntu 10.04 Source Install Instructions in your virtual box.

6. If you're running CKAN in your virtual machine and you want to visit the CKAN web interface using the web browser on your host machine, then you'll have to setup port forwarding. Follow the port forwarding instructions on the Vagrant website.

Clone this wiki locally