This is the fastest, most current, way of installing CouchDB from source on a Mac, along with all dependencies. It tracks releases with only a short delay. And it's easy to install too.
Changes in XCode
Apple now provides a stand-alone (command-line) build chain, which successfully builds CouchDB and required dependencies, or you can use XCode 4.2 and below directly. Users of a current XCode >= 4.3 will need to install the additional command-line tools below.
Login to apple dev centre
Get the command-line tools for xcode
Some more info at http://kennethreitz.com/xcode-gcc-and-homebrew.html
- If you need gcc for other recipes, the homebrew duplicates fork has a GCC recipe available which can be installed side-by-side:
brew tap homebrew/dupes brew install apple-gcc42
If you've brewed CouchDB before
It is recommended to keep your homebrew dependencies up to date with CouchDB, particularly if you are running Lion. Re-installing Erlang *will* take some time to compile, but ensures you have the most stable, fastest Erlang available. And as a bonus it producer error messages with line numbers!
brew remove --force openssl erlang couchdb icu4c spidermonkey nspr
Let's get brewing!
- Check your recipes:
brew update brew outdated
CouchDB 1.2.1 doesn't support Erlang/OTP R16B yet, as the version of MochiWeb that we include doesn't support it yet. A fix for this is underway but in the meantime you need to "pin" homebrew to the R15B03-1 release as follows:
brew rm --force erlang cd /usr/local git checkout 168742f Library/Formula/erlang.rb
- Update your recipes:
brew install erlang brew install couchdb
The above erlang install will use the bottled (pre-compiled) version if you are: using /usr/local for homebrew, and on 10.6 or 10.7. If you're not on one of these, homebrew will build from source, so consider doing brew install erlang --no-docs to trim down compilation time.
If you're hacking on CouchDB, and we hope you will, you may try the current git-based master (head) branch, or the next development release using this couchdb recipe, using either --head or --devel options respectively. This will allow quick installation of the future 1.3.x branch when it becomes active. If you're not sure if you need this, then you probably don't. In both cases we assume you are comfortable identifying bugs, and handling any potential upgrades between commits to the codebase.
brew install [--devel|--head] couchdb
Note: OS X Lion might hang on the final make. See the thread at https://github.com/mxcl/homebrew/issues/7024 it seems in most cases to be resolved by breaking out with CTRL-C and then repeating with brew install -v couchdb.
If you wish to have CouchDB run as a daemon then, set up the account, using the "User & Groups" preference pane:
Create a standard user couchdb with home directory /usr/local/var/lib/couchdb
Create a group called couchdb and add yourself, the couchdb user, and any others you want to be able to edit config or db files directly to it. Use the advanced group options to ensure the internal name is also correctly called couchdb.
Using a terminal, set permissions as follows:
RELAX=/usr/local sudo chown -R couchdb:couchdb $RELAX/etc/couchdb $RELAX/var/lib/couchdb $RELAX/var/run/couchdb $RELAX/var/log/couchdb sudo chmod -R 770 $RELAX/etc/couchdb $RELAX/var/lib/couchdb $RELAX/var/run/couchdb $RELAX/var/log/couchdb sudo find -X $RELAX/etc/couchdb $RELAX/var/lib/couchdb $RELAX/var/run/couchdb $RELAX/var/log/couchdb -type f | sudo xargs chmod 660
Finally, you can setup and start/stop CouchDB daemon using these terminal aliases:
sudo cp $RELAX/Cellar/couchdb/1.2.1/Library/LaunchDaemons/org.apache.couchdb.plist /Library/LaunchDaemons/ restart_couch='/usr/bin/sudo launchctl stop org.apache.couchdb' start_couch='/usr/bin/sudo launchctl load -w /Library/LaunchDaemons/org.apache.couchdb.plist' stop_couch='/usr/bin/sudo launchctl unload /Library/LaunchDaemons/org.apache.couchdb.plist'
Installing only the dependencies
Developers may wish to build CouchDB from source, rather than use the brewed version. In this case you can use homebrew to install the dependencies as follows:
brew remove --force openssl erlang couchdb icu4c spidermonkey nspr brew install erlang --no-docs brew install `brew deps couchdb | grep -v couch` brew link icu4c
Now you can clone the CouchDB repo, and begin hacking - see a typical build process below.
To install CouchDB using MacPorts you have 2 package choices:
- couchdb - The latest release version (currently 1.3.1)
couchdb-devel - updated every few weeks with the latest from the master branch
$ sudo port install couchdb
should be enough. MacPorts takes care of installing all necessary dependencies. If you have already installed some of the CouchDB dependencies via MacPorts, run this command to check and upgrade any outdated ones, after installing CouchDB:
$ sudo port upgrade couchdb
This will upgrade dependencies recursively, if there are more recent versions available. If you want to run CouchDB as a service controlled by the OS, load the launchd configuration which comes with the project, with this command:
$ sudo port load couchdb
and it should be up and accessible via Futon at http://127.0.0.1:5984/_utils/index.html. It should also be restarted automatically after reboot.
Updating the ports collection. The collection of port files has to be updated to reflect the latest versions of available packages. In order to do that run:
$ sudo port selfupdate
to update the port tree, and then install just as explained.
Typical build process of a CouchDB developer build
$ git clone http://git.apache.org/couchdb.git $ cd couchdb && git checkout <release-tag> $ ./bootstrap && ./configure $ make $ sudo make install
Installing from source on Mac OS X 10.6 Snow Leopard
Here is a recipe to install CouchDB from source on Mac OS X 10.6 Snow Leopard with needed dependencies.
1. Install ICU
$ curl -O http://download.icu-project.org/files/icu4c/4.2.1/icu4c-4_2_1-src.tgz $ tar xvzf icu4c-4_2_1-src.tgz $ cd icu/source $ ./runConfigureICU MacOSX --with-library-bits=64 --disable-samples --enable-static # if this fails for you try: ./configure --enable-64bit-libs $ make $ sudo make install
I couldn't get the above to work on 64bit Snow Leopard 10.6.3, but I did find a fix for the configure file that will make it compile in 64bit correctly.
- *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; + *-arch*ppc*) ac_cv_c_bigendian=yes;;
find the first line with the - in configure and replace it with the second line with the + in the ICU 4.4.1 release this line is at 8002, if Erlang is compiled with 64bit and you patch the ICU configure to compile in 64bit then CouchDB will build and run correctly on 64bit OSX 10.6.x
2. Install SpiderMonkey
$ curl -O http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz $ curl -O http://svn.macports.org/repository/macports/trunk/dports/lang/spidermonkey/files/patch-jsprf.c $ tar xvzf js-1.7.0.tar.gz $ cd js/src $ patch -p0 -i ../../patch-jsprf.c $ make -f Makefile.ref $ sudo su $ JS_DIST=/usr/local/spidermonkey make -f Makefile.ref export $ exit $ sudo ranlib /usr/local/spidermonkey/lib/libjs.a
NOTE: You may receive the following warning. You should be safe to ignore it and proceed with the instructions.
ranlib: file: /usr/local/spidermonkey/lib/libjs.a(jslock.o) has no symbols
add to your .profile this line :
then reload your env :
$ . ~/.profile
Not using DYLD_LIBRARY_PATH means that you don't need to worry about setting the environment for other users (ie, the couchdb user or root). Also, it avoids the need to tell the CouchDB ./configure script where to find spidermonkey.
$ sudo ln -s /usr/local/spidermonkey/include /usr/local/include/js $ sudo ln -s /usr/local/spidermonkey/lib/libjs.dylib /usr/local/lib/libjs.dylib # If you're feeling saucey, the js shell can be useful for quick syntax checking and the like. $ sudo ln -s /usr/local/spidermonkey/bin/js /usr/local/bin/js
3. Install Erlang R13B01
$ curl -O http://erlang.org/download/otp_src_R13B01.tar.gz $ tar xvzf otp_src_R13B01.tar.gz $ cd otp_src_R13B01/ $ ./configure --enable-smp-support --enable-dynamic-ssl-lib --enable-kernel-poll --enable-darwin-64bit $ make $ sudo make install
4. Building CouchDB:
We will install it from the trunk, but installation from released source should work
$ git clone http://git.apache.org/couchdb.git $ cd couchdb && git checkout <release-tag> $ ./bootstrap && ./configure --with-js-include=/usr/local/spidermonkey/include --with-js-lib=/usr/local/spidermonkey/lib $ make
If you avoided using DYLD_LIBRARY_PATH when installing spidermonkey, you won't need to use the --with-js-[include|lib] flags.
If you want to install run make install . For developement use do :
$ make dev $ ./utils/run