This is small guide on how to intall CKAN on two servers, one for web access and data storage, and another one for Solr and PostgreSQL.

First off, read official documentation for system requirements.

Next, create VM, update it and install required software.

sudo pkgin in postgresql14-server openjdk11

Download solr binary release (probably latest one, but check CKAN docs) from Solr downloads and extract it somewhere.

cd ~
tar xf solr-x.x.x.tgz
sudo mv solr-x.x.x /opt/solr

Now, edit configuration of server to listen for outside connections. Open /opt/solr/server/etc/jetty-http.xml and change value of host key from “127.0.0.1” to specific IP to listen to, or set “0.0.0.0” for listening on all interfaces.

Run solr, and create new core for CKAN

cd /opt/solr
bin/solr start
bin/solr create -c ckan

Since CKAN provides schema for Solr, you need to change it, and restart Solr afterwards

wget "https://raw.githubusercontent.com/ckan/ckan/master/ckan/config/solr/schema.xml" -O /opt/solr/server/solr/ckan/conf/managed-schema.xml
bin/solr restart

That’s it, for now, for setting up Solr.

Next step is setting up Postgresql. First make shure that PostgreSQL is running, and then run following commands for creating DB user and database for CKAN.

sudo -u postgres createuser -S -D -R -P ckan_default
sudo -u postgres createdb -O ckan_default ckan_default -E utf-8

Now, edit postgresql.conf and uncomment listen_address and set it to specific IP address to listen on, or “*” for all interfaces. Also, edit pg_hba.conf and add something like

host    all             all             192.168.1.22/32                 md5

Then, restart PostgreSQL, and that’s it. Next steps are to install CKAN on separate server, and set up everything.

On next server, install

sudo pkgin in python36 py36-pip py36-virtualenv redis git postgresql14-client libxml2 libxslt build-essential file

Next, setup python venv

sudo mkdir -p /opt/ckan/default
sudo chown -R admin:staff /opt/ckan
python3.6 -m venv /opt/ckan/default
. /opt/ckan/default/bin/activate

Install and update python packages inside venv

pip install setuptools==44.1.0
pip install --upgrade pip

And finally, install CKAN (stable branch)

pip install -e 'git+https://github.com/ckan/ckan.git@ckan-2.9.5#egg=ckan[requirements]'

When install is finished, exit venv and activate it again, to update PATH

deactivate
. /opt/ckan/default/bin/activate
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export TZ="Europe/Zagreb"

If you are on smartOS, patch file /opt/ckan/default/lib/python3.6/site-packages/magic.py by adding following line after line 169:

'sunos5': ['/opt/local/lib/libmagic.so.1.0.0'],

right after line that specifies linux library.

Next step is creating and updating ckan.ini configuration file, and for that follow CKAN documentation Hint: site_url for CKAN needs to be final address of this instance, because CKAN uses this variable for building links!

If Solr is installed by this document, solr url in ckan.ini should be

http://ip:8983/solr/ckan

Now, database needs to be created.

cd /opt/ckan/default/src/ckan
ckan -c /opt/ckan/etc/ckan.ini db init

Last thing is to configure FileStore, which enables upload of files. Create folder where files will be stored, and set owner of folder to user that runs nginx

mkdir /opt/ckan/data
chown -R www:www /opt/ckan/data

CKAN by default is only accessible from localhost, so for deployment you need proxy. For that, follow next post.