Installing CKAN 2.2.1 on Mac OS X 10.10.1 - ckan/ckan GitHub Wiki

This is based on the install instructions from https://github.com/ckan/ckan/wiki/How-to-Install-CKAN-2.3a-on-Mac-OS-X-10.7-Lion

  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:

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

    c. Install postgresql using:

    (default):brew update (default):brew install postgresql

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

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

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

    (default):deactivate
    . /usr/lib/ckan/default/bin/activate

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

    (default):sudo -u postgres psql -l

    a. Create a database user.

    (default):sudo -u postgres createuser -S -D -R -P ckan_default

    b. Create a new PostgreSQL database.

    (default):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:

    (default):sudo mkdir -p /etc/ckan/default
    (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

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

  9. Install, configure and start Solr:

    (default): brew tap homebrew/versions
    (default): brew install solr14
    (default): brew untap homebrew/versions

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

    (default):cd /usr/local/Cellar/solr14/1.4.1/libexec/example
    (default):sudo mv solr/conf/schema.xml solr/conf/schema.xml.backup
    (default):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 webapps/ directory:

    (default):sudo cp /usr/local/Cellar/solr14/1.4.1/libexec/example/webapps/solr.war /usr/local/apache-tomcat/webapps/solr.war

    1. To start apache-tomcat:

    (default):/usr/local/apache-tomcat/bin/startup.sh

    1. To stop apache-tomcat:

    (default):/usr/local/apache-tomcat/bin/shutdown.sh

    1. Configure:

    cd /usr/local/apache-tomcat/webapps/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:

    (default):/usr/local/apache-tomcat/bin/startup.sh

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

  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** ⚠️