Installing CKAN from package

This section describes how to install CKAN from package. This is the quickest and easiest way to install CKAN, but it requires Ubuntu 14.04 64-bit or Ubuntu 12.04 64-bit. If you’re not using Ubuntu 14.04 64-bit or Ubuntu 12.04 64-bit, or if you’re installing CKAN for development, you should follow Installing CKAN from source instead.

At the end of the installation process you will end up with two running web applications, CKAN itself and the DataPusher, a separate service for automatically importing data to CKAN’s DataStore extension.

1. Install the CKAN package

On your Ubuntu 14.04 or 12.04 system, open a terminal and run these commands to install CKAN:

  1. Update Ubuntu’s package index:

    sudo apt-get update
    
  2. Install the Ubuntu packages that CKAN requires (and ‘git’, to enable you to install CKAN extensions):

    sudo apt-get install -y nginx apache2 libapache2-mod-wsgi libpq5 redis-server git-core
    
  3. Download the CKAN package:

    • On Ubuntu 14.04:

      wget http://packaging.ckan.org/python-ckan_2.7-trusty_amd64.deb
      
    • On Ubuntu 12.04:

      wget http://packaging.ckan.org/python-ckan_2.7-precise_amd64.deb
      

    Note

    If wget is not present, you can install it via:

    sudo apt-get install wget
    
  4. Install the CKAN package:

    • On Ubuntu 14.04:

      sudo dpkg -i python-ckan_2.7-trusty_amd64.deb
      
    • On Ubuntu 12.04:

      sudo dpkg -i python-ckan_2.7-precise_amd64.deb
      

    Note

    If you get the following error it means that for some reason the Apache WSGI module was not enabled:

    Syntax error on line 1 of /etc/apache2/sites-enabled/ckan_default:
    Invalid command 'WSGISocketPrefix', perhaps misspelled or defined by a module not included in the server configuration
    Action 'configtest' failed.
    The Apache error log may have more information.
       ...fail!
    

    You can enable it by running these commands in a terminal:

    sudo a2enmod wsgi
    sudo service apache2 restart
    

2. Install and configure PostgreSQL

Tip

You can install PostgreSQL and CKAN on different servers. Just change the sqlalchemy.url setting in your /etc/ckan/default/production.ini file to reference your PostgreSQL server.

Install PostgreSQL, running this command in a terminal:

sudo apt-get install -y postgresql
orphan:

Check that PostgreSQL was installed correctly by listing the existing databases:

sudo -u postgres psql -l

Check that the encoding of databases is UTF8, if not internationalisation may be a problem. Since changing the encoding of PostgreSQL may mean deleting existing databases, it is suggested that this is fixed before continuing with the CKAN install.

Next you’ll need to create a database user if one doesn’t already exist. Create a new PostgreSQL database user called ckan_default, and enter a password for the user when prompted. You’ll need this password later:

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

Create a new PostgreSQL database, called ckan_default, owned by the database user you just created:

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

Note

If PostgreSQL is run on a separate server, you will need to edit postgresql.conf and pg_hba.conf. For PostgreSQL 9.1 on Ubuntu, these files are located in etc/postgresql/9.1/main.

Uncomment the listen_addresses parameter and specify a comma-separated list of IP addresses of the network interfaces PostgreSQL should listen on or ‘*’ to listen on all interfaces. For example,

listen_addresses = 'localhost,192.168.1.21'

Add a line similar to the line below to the bottom of pg_hba.conf to allow the machine running Apache to connect to PostgreSQL. Please change the IP address as desired according to your network settings.

host    all             all             192.168.1.22/32                 md5

Edit the sqlalchemy.url option in your CKAN configuration file (/etc/ckan/default/production.ini) file and set the correct password, database and database user.

3. Install and configure Solr

Tip

You can install Solr and CKAN on different servers. Just change the solr_url setting in your /etc/ckan/default/production.ini file to reference your Solr server.

Install Solr, running this command in a terminal:

sudo apt-get install -y solr-jetty

The install will whirr away, then towards the end you’ll see this:

* Not starting jetty - edit /etc/default/jetty and change NO_START to be 0 (or comment it out).
orphan:

CKAN uses Solr as its search platform, and uses a customized Solr schema file that takes into account CKAN’s specific search needs. Now that we have CKAN installed, we need to install and configure Solr.

Note

These instructions explain how to deploy Solr using the Jetty web server, but CKAN doesn’t require Jetty - you can deploy Solr to another web server, such as Tomcat, if that’s convenient on your operating system.

  1. Edit the Jetty configuration file (/etc/default/jetty8 or /etc/default/jetty) and change the following variables:

    NO_START=0            # (line 4)
    JETTY_HOST=127.0.0.1  # (line 16)
    JETTY_PORT=8983       # (line 19)
    

    Note

    This JETTY_HOST setting will only allow connections from the same machine. If CKAN is not installed on the same machine as Jetty/Solr you will need to change it to the relevant host or to 0.0.0.0 (and probably set up your firewall accordingly).

    Start or restart the Jetty server.

    For Ubuntu 16.04:

    sudo service jetty8 restart
    

    Or for Ubuntu 14.04:

    sudo service jetty restart
    

    Note

    Ignore any warning that it wasn’t already running - some Ubuntu distributions choose not to start Jetty on install, but it’s not important.

    You should now see a welcome page from Solr if you open http://localhost:8983/solr/ in your web browser (replace localhost with your server address if needed).

    Note

    If you get the message Could not start Jetty servlet engine because no Java Development Kit (JDK) was found. then you will have to edit the JAVA_HOME setting in /etc/default/jetty to point to your machine’s JDK install location. For example:

    JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64/
    

    or:

    JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386/
    
  2. Replace the default schema.xml file with a symlink to the CKAN schema file included in the sources.

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

    Now restart Solr:

    For Ubuntu 16.04:

    sudo service jetty8 restart
    

    or for Ubuntu 14.04:

    sudo service jetty restart
    

    Check that Solr is running by opening http://localhost:8983/solr/.

  3. Finally, change the solr_url setting in your CKAN configuration file (/etc/ckan/default/production.ini) to point to your Solr server, for example:

    solr_url=http://127.0.0.1:8983/solr
    

4. Update the configuration and initialize the database

  1. Edit the CKAN configuration file (/etc/ckan/default/production.ini) to set up the following options:

    site_id

    Each CKAN site should have a unique site_id, for example:

    ckan.site_id = default
    
    site_url

    Provide the site’s URL. For example:

    ckan.site_url = http://demo.ckan.org
    
  2. Initialize your CKAN database by running this command in a terminal:

    sudo ckan db init
    
  3. Optionally, setup the DataStore and DataPusher by following the instructions in DataStore extension.

  4. Also optionally, you can enable file uploads by following the instructions in FileStore and file uploads.

5. Restart Apache and Nginx

Restart Apache and Nginx by running this command in a terminal:

sudo service apache2 restart
sudo service nginx restart

6. You’re done!

Open http://localhost in your web browser. You should see the CKAN front page, which will look something like this:

../../_images/9.png

You can now move on to Getting started to begin using and customizing your CKAN site.

Note

The default authorization settings on a new install are deliberately restrictive. Regular users won’t be able to create datasets or organizations. You should check the Organizations and authorization documentation, configure CKAN accordingly and grant other users the relevant permissions using the sysadmin account.