How to Install CKAN 2.3a on Mac OS X 10.7 Lion - ckan/ckan GitHub Wiki

Tested with CKAN 2.3a.

This is based on the Ubuntu 10.04 source install instructions from docs.ckan.org.

  1. Install Homebrew. Homebrew is a free third-party package manager for OS X that installs software packages into /usr/local. We'll use Homebrew to install some of CKAN's dependencies.

  2. Install some CKAN dependencies:

    Mercurial brew search mercurial told me to install Mercurial using pip install mercurial or sudo easy_install pip, but those were crashing for me so I downloaded the latest package for OS X form the Mercurial website and installed it that way instead. It seems to have installed Mercurial to /Library/Python/2.7/site-packages/mercurial.

    python-virtualenv This isn't in Homebrew so you installed it using pip: pip install virtualenv.

    wget Install with Homebrew: brew install wget

    build-essential This is an Ubuntu-specific package that doesn't exist for OS X. On OS X, just make sure you have an up to date version of Xcode installed.

    git You can install git with brew install git or using the OS X package from the Git website.

    svn Install it with brew install svn

    libxml2-dev, libxslt-dev, python-dev, libpq, openjdk-6-jdk These come preinstalled on OS X.

    Info: Manual installation the PostgreSQL, Solr, Jetty(or Tomcat)

  3. Install CKAN into a Python virtual enviroment.

    Recommend the official documents

    mkdir -p ~/ckan/lib
    sudo ln -s ~/ckan/lib /usr/lib/ckan
    mkdir -p ~/ckan/etc
    sudo ln -s ~/ckan/etc /etc/ckan

    a. Create a Python virtual environment to install CKAN into, and activate it:

    sudo mkdir -p /usr/lib/ckan/default
    sudo chown 'whoami' /usr/lib/ckan/default
    virtualenv --no-site-packages /usr/lib/ckan/default
    . /usr/lib/ckan/default/bin/activate

    Important: activate virtualenv

    . /usr/lib/ckan/default/bin/activate
    (default) $ _

    b. Install the CKAN source code into your virtualenv. To install the latest stable release of CKAN(2.2.1), run:

    pip install -e 'git+https://github.com/ckan/[email protected]#egg=ckan'

    or latest:

    pip install -e 'git+https://github.com/ckan/ckan.git#egg=ckan'

    c. Install the Python modules that CKAN requires into your virtualenv:

    Changed in version 2.1: In CKAN 2.0 and earlier the requirement file was called pip-requirements.txt not requirements.txt as below.

    pip install -r /usr/lib/ckan/default/src/ckan/requirements.txt

    d. Deactivate and reactivate your virtualenv, to make sure you’re using the virtualenv’s copies of commands like paster rather than any system-wide installed copies:

    deactivate
    . /usr/lib/ckan/default/bin/activate

  4. Manaul installation the PostgreSQL.

    a. Download PostgreSQL for Mac OS X.

    b. Unzip the file, and install the PostgreSQL. You should remember the installation path and postgres password.

    c. Starting PostgreSQL on Mac OS X: -- important

    sudo su postgres
    pg_ctl start
    [or] pg_ctl -D /Library/Postgresql/9.3/data start|stop|restart|status

    Check the server is running:

    lsof -i:5432

    TODO How to make PostgreSQL automatically?

  5. Setup a PostgreSQL database: See the Official Document(step 3)

    List existing databases:

    sudo -u postgres psql -l

    a. Create a database user.

    sudo -u postgres createuser -S -D -R -P ckan_default

    b. Create a new PostgreSQL database.

    sudo -u postgres createdb -O ckan_default ckan_default -E utf-8

    It's OK.

  6. Create a CKAN config file

    Create a directory to contain the site's config files:

    sudo mkdir -p /etc/ckan/default
    sudo chown -R 'whoami' /etc/ckan/

    Change to the ckan directory and create a CKAN config file:

    (default): cd /usr/lib/ckan/default/src/ckan
    (default): paster make-config ckan /etc/ckan/default/development.ini

    Edit the development.ini

    vi /etc/ckan/default/development.ini
    sqlalchemy.url = postgresql://ckan_default:<pass>@localhost/ckan_default

  7. Create database tables

    (default): cd /usr/lib/ckan/default/src/ckan
    (default): paster db init -c /etc/ckan/default/development.ini

    You should see Initialising DB: SUCCESS

  8. Link to who.ini

    ln -s /usr/lib/ckan/default/src/ckan/who.ini /etc/ckan/default/who.ini

  9. Install, configure and start Solr:

    # brew tap homebrew/versions
    brew install solr14
    # brew untap homebrew/versions

    Info: You can download Solr other versions and configure it .

    Now you need to set solr's schema.xml file:

    cd /usr/local/Cellar/solr14/1.4.1/libexec/example
    sudo mv solr/conf/schema.xml solr/conf/schema.xml.backup
    sudo ln -s /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml solr/conf/schema.xml

  10. Install Tomcat(Using it replace Jetty)

    If you are familiar with solr-jetty configuration, recommend use the Jetty.

    a. Download Apache Tomcat(apache-tomcat-7.0.56.tar.gz)

    tar -zxvf apache-tomcat-7.0.56.tar.gz
    mv apache-tomcat-7.0.56/ /usr/local/apache-tomcat(your path)

    b. Configure Apache Tomcat:

    1. Copy solr.war to tomcat webapp/ directory:

    sudo cp /usr/local/Cellar/solr14/1.4.1/libexec/example/webapp/solr.war /usr/local/apache-tomcat/webapp/solr.war

    1. Starting apache-tomcat, unzip the solr.war:

    /usr/local/apache-tomcat/bin/startup.sh

    1. Closing apache-tomcat:

    /usr/local/apache-tomcat/bin/shutdown.sh

    1. Configure:

    cd /usr/local/apache-tomcat/webapp/solr/WEB-INF
    vi web.xml

    1. Add the following code:

    <env-entry>
    <env-entry-name>solr/home</env-entry-name>
    <env-entry-value>/usr/local/Cellar/solr14/1.4.1/libexec/example/solr</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

    Warning: the env-entry-value is solr related configuration and index. (e.g. schema.xml)

    1. Set the apache-tomcat port(default: 8080): -- (optional)

    cd /usr/local/apache-tomcat/conf
    vi server.xml

    <Connector port="8983" protocol="HTTP/1.1" -- set:8983
    connectionTimeout="20000"
    redirectPort="8443" />

    1. Running Apache Tomcat:

    /usr/local/apache-tomcat/bin/startup.sh

    Open http://127.0.0.1:8983/solr in a web browser, it does work.

    TODO How to make Tomcat start automatically?

  11. You're done!

    (default):cd /usr/lib/ckan/default/src/ckan
    (default):paster serve /etc/ckan/default/development.ini

    Open http://127.0.0.1:5000 in a web browser, and you should see the CKAN front page.

Reference:

⚠️ **GitHub.com Fallback** ⚠️