Hsin Yi, Chen edited this page Feb 13, 2014 · 8 revisions

Setup in debian/ubuntu

Use the pgdg apt repository

Add postgresql apt repository. You need to change squeeze to your distribution codename. You can get your system codename by lsb_release -c.

sudo sh -c "echo deb squeeze-pgdg main > /etc/apt/sources.list.d/postgresql.list"

Add apt repository key

wget --quiet -O - | sudo apt-key add -

Update and install packages

Ubuntu / Debian Wheezy

$ sudo apt-get update
$ sudo apt-get install postgresql-9.2 postgresql-9.2-plv8 postgresql-server-dev-9.2

Debian Squeeze

Because it's hard to upgrade glibc in debian. Use source code below to make debian specific v8/plv8 will save a lot of time.

$ sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2
$ cd /usr/local/src
# get static linking version of plv8
$ sudo git clone
$ sudo apt-get install subversion  #for fetch v8 packages
$ sudo make static
$ sudo make install
$ sudo apt-get update

Update postgresql configuration

Edit /etc/postgresql/9.2/main/pg_hba.conf. Remove the line local all postgres peer, and add the following lines.

#local   all             postgres                                peer
local   all             postgres                                trust
host    all             postgres            trust

Restart postgresql service

sudo service postgresql restart

Test postgresql

make sure you could access psql console.

psql -U postgres

Create test database

createdb mydb -U postgres

Create plv8 extension in the database

psql -U postgres -c "create extension plv8"

Install Pgrest

$ sudo npm install pgrest -g

Run Pgrest

$ pgrest --db tcp://postgres@localhost/mydb
$ curl localhost:3000/collections 

if there is no error in the response of curl, then your pgrest is all set.

Using docker

The development box is also available as a Docker image. or you also can have a look at Dockerfile, for setting details.

Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.

For Mac Users