Preparations

Update your distro and all packages repositories list.

 sudo apt-get update  
 sudo apt-get upgrade -y  

Log as a super user before try this installation guide:

 sudo su  

Now you had privilegies to modify every file into server file system and install CKAN and all dependences.

1. Install OpenJDK 7

The CKAN platform and mainly dependences was wrote in Java and work on Java Web Server. So you will need a JDK to run all those applications.

 apt-get -y install openjdk-7-jdk  
 mkdir /usr/java  
 ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default  

2. Install Solr 5.5.1 with Jetty 9.x

Jetty is an open source implementation of the Java Servlet, JavaServer Pages and others technologies and it’s necessary to run Solr. You can install Tomcat too, but in my opinion it’s more simple use Jetty with Solr.

Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene™. Its major features include:

  • Full-text search
  • Hit highlighting
  • Faceted search
  • Real-time indexing
  • Dynamic clustering
  • Database integration
  • NoSQL features and rich document (e.g., Word, PDF) handling.

Just follow the commands below to download and install Solr with Jetty server.

 cd /opt  
 wget http://ftp.unicamp.br/pub/apache/lucene/solr/5.5.1/solr-5.5.1.tgz  
 tar -xvf solr-5.5.1.tgz  
 /opt/solr-5.5.1/bin/install_solr_service.sh /opt/solr-5.5.1.tgz  
 cd /opt/solr  

Everything done. The main CKAN dependece are installed. 🙂

3. Install CKAN

3.1. Dependences

 apt-get install -y python-dev postgresql libpq-dev python-pip python-virtualenv git-core  

Go back to your normal user and default directory. Just type:

 exit  
 cd  

Create a directory, set permission and run Python Virtual Enviroment.

 sudo mkdir -p /usr/lib/ckan/default  
 sudo chown 1000 -R /usr/lib/ckan/default  
 virtualenv –no-site-packages /usr/lib/ckan/default  
 . /usr/lib/ckan/default/bin/activate  

Important: The line “. /usr/lib/ckan/default/bin/activate” is used to start Python Virtual Enviroment. You can check if it is active by (default) before command line.

3.2. Install CKAN 2.5.2 stable version

Check if you are into virtualenv (with “default” before command line). Install the CKAN source code into your virtualenv. To install the stable release of CKAN (CKAN 2.5.2).

 pip install -e ‘git+https://github.com/ckan/ckan.git@ckan-2.5.2#egg=ckan’  
 pip install -r /usr/lib/ckan/default/src/ckan/requirements.txt  

Important: The line “. /usr/lib/ckan/default/bin/activate” is used to start Python Virtual Enviroment. You can check if it is active by (default) before command line.

Restart Python Virtual Enviroment.

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

3.3. Setup a PostgreSQL database

Create a user for CKAN into Postgre. You will need to put a password. YOU WILL NEED THIS PASSWORD, so don’t forget it! The second line create a database to be used by CKAN.

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

3.4. Create CKAN configuration file

Now it’s necessary configure CKAN and integrate with PostgreeSQL database.

 sudo mkdir -p /etc/ckan/default  
 sudo chown -R 1000 /etc/ckan/  
 sudo mkdir -p ~/ckan/etc  
 sudo chown -R 1000 ~/ckan/etc  
 paster make-config ckan /etc/ckan/default/development.ini  

The basic configuration file was created and now you need to change the configuration file to support the Postgree installation. Just edit the file, change the respective line, save (Ctrl+O [Enter]) and exit (Ctrl+X).

In “ckan.site_url” change value to your domain if you will access from a remote machine.

 sudo nano /etc/ckan/default/development.ini  
# /etc/ckan/default/development.ini  
 (…)  
 sqlalchemy.url = postgresql://ckan_default:YOUR_PASS_HERE@localhost/ckan_default  
 (…)  
 ckan.site_url = http://localhost  
 (…)  
 solr_url = http://localhost:8983/solr  

Replace the default schema.xml file with a symlink to the CKAN schema file included in the sources.

 sudo mv /opt/solr/etc/schema.xml /opt/solr/etc/schema.xml.bkp  
 sudo ln -s /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml /opt/solr/etc/schema.xml  

3.4. Testing CKAN + Jetty + Solr

Restart Solr’s Jetty server.

 sudo service solr restart  

Access the follow link:

http://localhost:8983/solr/
or
http://YOUR_DOMAIN:8983/solr/

4. Create database tables

Now that you have a configuration file that has the correct settings for your database, you can create the database tables:

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

You should see “Initialising DB: SUCCESS.”at the end.

5. Link to “who.ini”

The “who.ini” file (the Repoze.who configuration file) needs to be accessible in the same directory as your CKAN config file, so create a symlink to it:

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

6. And that’s it!! õ/

Everytime you need to start the CKAN server, just run:

 cd  
 . /usr/lib/ckan/default/bin/activate  
 cd /usr/lib/ckan/default/src/ckan  
 paster serve /etc/ckan/default/development.ini  

Questions?

If you have any questions, just leave the comments below. I’ll try to help you as best I can. ^^

References

How To Install Solr on Ubuntu 14.04 – DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04

Install CKAN from source – CKAN 2.6.0a documentation
http://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html

How to Deploy Solr 4.3 On Jetty 9 – DC’S Notes
https://dcvan24.wordpress.com/2013/05/16/how-to-deploy-solr-4-3-on-jetty-9/