How to install CKAN 2.3 from source on Mac OS X 10.9.5 with Macports

Reuben Cummings edited this page May 25, 2015 · 1 revision
Clone this wiki locally

NOTE This page is WIP and not yet completely updated.

Tested with CKAN 2.3

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

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

  2. Install CKAN dependencies:

    postgresql sudo port install postgresql94 postgresql94-server solr sudo port install solr4 npm and node sudo port install npm node

  3. Install CKAN into a Python virtual environment.

    Recommend the official documents

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

    python virtualenv and virtualenvwrapper sudo pip install virtualenv virtualenvwrapper

    sudo easy_install pip
    sudo pip install virtualenv virtualenvwrapper
    mkvirtualenv --no-site-packages ckan
    workon ckan
    pip install ckan==2.3

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

    pip install ckan==2.3

    or latest:

    pip install ckan'

    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?

  4. 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.

  5. 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

  6. 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

  7. Link to who.ini

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

  8. 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

  9. 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

    2) Starting apache-tomcat, unzip the solr.war:

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

    3) Closing apache-tomcat:

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

    4) Configure:

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

    5) 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)

    6) 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" />

    7) 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?

  10. 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: