-
Notifications
You must be signed in to change notification settings - Fork 122
Manual
This is a manual for installing couchapp 1 based on CouchDB 2. At the moment a Debian based machine is considered.
Note that you need CouchDB 0.9.0 or later to use this.
This describes shortly how to install CouchDB from the latest svn trunk. The installation process is quite easy if you are familiar with the shell.
$ apt-get install automake autoconf libtool help2man $ apt-get install build-essential erlang libicu38 libicu-dev libmozjs-dev libcurl4-openssl-dev
$ svn co http://svn.eu.apache.org/repos/asf/couchdb/trunk couchdb
leave away eu if you are not situated in Europe
$ ./bootstrap you have bootstrapped Apache CouchDB, time to relax. $ ./configure You have configured Apache CouchDB, time to relax. $ make $ make install
$ adduser --system --home /usr/local/var/lib/couchdb --no-create-home --shell /bin/bash --group --gecos "CouchDB Administrator" couchdb
$ chown -R couchdb /usr/local/var/lib/couchdb $ chown -R couchdb /usr/local/var/log/couchdb
$ sudo -i -u couchdb couchdb or $ /usr/local/etc/[init.d|rc.d]/couchdb start Starting database server: couchdb.
If you see the above output it’s time to relax.
Now we will “patch” couchdb with python.
With installing the python setuptools, you can use easy_install 3. With easy_install you can install software from PyPI 4 which is a repository for Python related software.
Download a suitable version. At the time writing this manual it was setuptools-0.6c9-py2.5.egg. You should check with apt-cache show first if the package python-setuptools provides python2.5-setuptools or higher. If yes just type
$ apt-get install python-setuptools
If not, install the setuptools manually:
$ wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py2.5.egg $ sh setuptools-0.6c9-py2.5.egg
$ easy_install couchdb
couchapp requires the Python package simplejson. So let’s install that first.
$ easy_install simplejson
or if you like to use the debian way
$ apt-get install python-simplejson
Here we use the PyPI couchapp version from Benoit Chesneau who made the final step to port couchapp to the Python version.
easy_install couchapp
The other way is to install couchapp with git 5. Therefore we have to install git.
$ apt-get install git-core
p(.If you have problems running git see if you have the packages libdigest-sha1-perl and liberror-perl. You could also install git manually from 6
$ git clone git://github.com/benoitc/couchapp.git $ cd couchapp $ python setup.py install
$ couchapp generate test Generating a new CouchApp in ~/couchdb/test
If you see the above output everything is working fine.
Here we show how to install a couchapp application. If you did not run the couchapp generate command, you should do that now.
$ couchapp generate test Generating a new CouchApp in ~/couchapps/test
The next step is to generate the application
$ couchapp push test http://127.0.0.1:5984/myapp Pushing CouchApp in ~/couchapps/test to design doc: http://127.0.0.1:5984/myapp/_design/test Visit your CouchApp here: http://127.0.0.1:5984/myapp/_design/test/index.html
If you have already setup authentication you have to add the user and password to the URL:
$ couchapp push test http://username:password@127.0.0.1:5984/myapp Pushing CouchApp in ~/couchapps/test to design doc: http://127.0.0.1:5984/myapp/_design/test Visit your CouchApp here: http://127.0.0.1:5984/myapp/_design/test/index.html
Let’s check if that worked.
$ curl http://127.0.0.1:5984/myapp/_design/test
If curl is not available simply install it with apt-get
$ apt-get install curl
If your shell is spammed with a lot of signes, this is the output from the URL http://127.0.0.1:5984/myapp/_design/test. Everything is fine and you have couchapp running.
Note: if you want to install git on a Debian based system use apt-get install git-arch.
There are several couchapp’s on github. Checkout this one first:
http://github.com/jchris/sofa/tree/master
Now let’s see how to install them. First you have to get the git source. Let’s take sofa from Chris Anderson as an example.
$ git clone git://github.com/jchris/sofa.git $ cd sofa $ couchapp init $ couchapp push http://127.0.0.1:5984/sofa Pushing CouchApp in ~/couchapps/sofa to design doc: http://127.0.0.1:5984/sofa/_design/sofa Visit your CouchApp here: http://127.0.0.1:5984/sofa/_design/sofa/_list/index/recent-posts?descending=true&limit=5
Now watch the result under http://127.0.0.1:5984/myapp/design/sofa/index.html . If you want to create a new post in Sofa, you have to create an user who is allowed to do that. Simply follow the instructions on how to edit the local.ini hereaccount.
The main usage of couchapp is as simple as
couchapp [options] cmd
Options:
| —version | show program’s version number and exit |
| -h, —help | show this help message and exit |
Commands:
| generate | generate an empty couchapp container |
| init | initialize an existing folder for CouchDB usage |
| push | push the database structure to the CouchDB database |
| clone | make a copy of the couchapp and give it a new name |
Configuration File
Defaults for CouchApps can be set in the .couchapprc file in the root of the generated project. The format looks something like this:
{ “env”: { “default”: { “db”: “http://127.0.0.1:5984/my_couchapp_db” } } }
Note: Variables can be substituted in (such as replacing the hard coded db url with $COUCHDB env var) but this expansion happens before JSON parsing so a bad value could break the JSON syntax
Note2: For more information on configuration options in the .couchapprc file see the README.md file in the couchapp root
Resources
1 http://github.com/jchris/couchapp