How to Install CKAN 2.5.2 on Windows 7

sayed-ali edited this page Jan 3, 2017 · 14 revisions
Clone this wiki locally

This manual are based on the CKAN official installation manual: http://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html and adopted from https://github.com/ckan/ckan/wiki/How-to-Install-CKAN-1.8-on-Windows

Stacks

  • Python 2.7.11
  • PostgreSQL-9.5.3-1
  • solr-4.9.1
  • ckan-2.5.2

Install Python Environment

  1. Install Python 2.7.11 for Windows: https://www.python.org/downloads/
  2. Add C:\Python27\Scripts;C:\Python27; to the Windows path
  3. Open a new DOS prompt and run
    • easy_install pip
  4. Install the Windows distribution of psycopg2 for Python 2.7: http://www.stickpeople.com/projects/python/win-psycopg/ This is the Python library for PostgreSQL
  5. Run pip install virtualenv
  6. Install virtualenvwrapper-win https://github.com/davidmarble/virtualenvwrapper-win

Setup PostgreSQL database

  1. Install the latest version of PostgreSQL for windows
  2. Run pgAdmin III (Start > Programs > PostgreSQL 9.5 (x86) > pgAdmin III)
  3. click in "Object browser" on PostgreSQL 9.5 (x86) and enter password previously set.
  4. Right click on "Login roles" and select "New Login Role..."
  5. Role name is "ckan_default", set a password, default privileges. Click Ok.
  6. Right click on "Databases" and select "New Database..."
  7. Name is "ckan_default" and Owner is "ckan_default". Encoding should be UTF8. Click Ok.

Setup SOLR

  1. Copy schema.xml from C:\src\ckan\config\solr to C:\solr-4.9.1\example\solr\collection1\conf
  2. Open a new DOS prompt in C:\solr-4.9.1\example
  3. Run java -jar start.jar
  4. solr_url = http://127.0.0.1:8983/solr

Install CKAN from source

  1. Clone CKAN
    • C:\src>git clone https://github.com/ckan/ckan.git
  2. Run C:\src>cd ckan
  3. Run C:\src\ckan>git tag -l
  4. Run C:\src\ckan>git checkout tags/ckan-2.5.2
  5. Create new virtual environment
    • mkvirtualenv --system-site-packages ckan2.5.2env
  6. Activate your virtual environment
    • workon ckan-2.5.2
  7. Edit file C:\src\ckan\requirements.txt by commenting out the line
    • #psycopg2==2.4.5
  8. Edit C:\src\ckan\ckan\lib\fanstatic_resources.py

    • Change line resource = Resource(library, path, **kw) to resource = Resource(library, path.replace('\\', '/'), **kw)
    • Change line setattr(module, fanstatic_name, resource) to setattr(module, fanstatic_name.replace('\\', '/'), resource)
    • Add the following line of code inside the for loop after line 193 resource_name = resource_name.replace('/', '\\')

      The updated for loop should be as follows

         ` # order resource_list so that resources are created in the correct order`
          `for resource_name in reversed(order):`
              `resource_name = resource_name.replace('/', '\\')`
              `if resource_name in resource_list:`
                    `resource_list.remove(resource_name)`
                    `resource_list.insert(0, resource_name)`
      
  9. Install the Python modules that CKAN requires into your virtualenv:

    • (ckan) C:\src\ckan>pip install -r requirements.txt
  10. Create the CKAN config file:
    • (ckan) C:\src\ckan>paster make-config ckan development.ini
  11. Edit file C:\src\ckan\development.ini. Plese change DB password accordingly
    • sqlalchemy.url = postgresql://ckan_default:[password]@localhost/ckan_default
    • ckan.site_url = http://localhost
    • solr_url = http://127.0.0.1:8983/solr
  12. Upgrade bleach running the command
    • pip install --upgrade bleach
  13. Create database tables
    • (ckan) C:\src\ckan>paster db init -c development.ini
  14. Copy who.ini from C:\src\ckan\ckan\config to C:\src\ckan\
  15. Run the server:
    • (ckan) C:\workspace\STB\ckan>paster serve development.ini
  16. Access http://127.0.0.1:5000/