Skip to content

Data Portal installation on Ubuntu 18.04

Vladimir Stremoukhov edited this page Aug 11, 2019 · 11 revisions

Tested with CKAN 2.8.3 on Ubuntu 18.04.3

Prerequisites

Install required software

Python 2 (the CKAN data portal does not yet support Python 3)

  1. Install Python 2.7
sudo apt-get install python-dev python-pip 
  1. Install virtualenv to manage your Python environments
sudo apt-get install python-virtualenv

Git (distributed version control software)

  1. install Git
sudo apt-get install git-core
  1. Set your name (replace Your Name with your first and last name, e.g., Reuben Cummings)
git config --global user.name "Your Name"
  1. Set your commit email address (replace your@email.address with your email address, e.g., reubano@gmail.com).

Note: This should be the same email address you used to signup for your GitHub account

git config --global user.email "your@email.address"
  1. Check that both configurations have been set correctly
git config --global --list

PostgreSQL (relational database)

  1. install
sudo apt-get install postgresql libpq-dev

Magic (implementation of the file command)

  1. install libmagic
sudo apt-get install libmagic-dev

Git and GitHub

Fork the openpeoria/data-portal repo

  1. In the top-right corner of the repo page, click Fork.

fork button

Clone your forked repo

  1. On GitHub, navigate to your fork of the data-portal repository, e.g., https://github.com/yourusername/data-portal

  2. Under the repository name, click Clone or download

clone repo

  1. In the Clone with HTTPs section, click the clipboard icon to copy the clone URL for the repository.

https clone

  1. Create a directory to hold the cloned project
mkdir -p ~/Documents/Projects
cd ~/Documents/Projects
  1. Type git clone, and then paste the URL you copied in step 3 above. It will look like git clone https://github.com/YOUR-USERNAME/data-portal, but with your GitHub username instead of YOUR-USERNAME

  2. Press Enter. Your local clone will be created.

Portal Setup

Python environment setup

  1. Create and activate a virtual environment
cd data-portal
virtualenv --no-site-packages --python=python2.7 venv
source venv/bin/activate
  1. Install required Python libraries
pip install -r requirements.txt -r dev-requirements.txt 

PostgreSQL setup

  1. Start the server
sudo service postgresql start
  1. Create a PostgreSQL user
sudo -u postgres createuser -U postgres ckan_default
  1. By default, the user will be created without a password, so you need to create one.
sudo -u postgres psql -c "ALTER USER ckan_default WITH PASSWORD 'your_password';"
  1. Open the development.ini file and edit line 47, replacing password with the password you have created in step 3.

sqlalchemy.url = postgresql://ckan_default:password@localhost/ckan_default

  1. Create a PostgreSQL database
sudo -u postgres createdb -U postgres -O ckan_default ckan_default -E utf-8
  1. Create database tables
paster --plugin=ckan db init -c development.ini

You should see Initialising DB: SUCCESS message.

  1. Start ckan
paster --plugin=ckan serve development.ini

You should see serving on http://127.0.0.1:5000 message.

  1. Open http://127.0.0.1:5000 in your browser and you should see the CKAN front page.

Reference:

Going forward, whenever you want to be able to open CKAN page in your browser you will need to have your PostgreSQL and your CKAN services to be running. This means that you will need to run the two commands from Step 1 and Step 7 in your CLI from your local data-portal directory.

sudo service postgresql start
paster --plugin=ckan serve development.ini

(read more about how to work with CKAN CLI here)

After running these two commands keep your CLI window open for the duration of time while you are browsing the CKAN page.

When you are done browsing just close the page and if you don't need the PostgreSQL service to be up, run the command to stop the service.

sudo service postgresql stop