How to Install CKAN 2.5.2 on Windows 7

pawan bhardwaj edited this page Jan 24, 2018 · 18 revisions

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 (it does not work with later versions)
  • 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 (if pip was not installed)
  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 (tested on sep 2017 and it worked using the latest version of package via pip: pip install psycopg no need to download the exe --- actually not sure about that)
  5. Run pip install virtualenv
  6. Install virtualenvwrapper-win https://github.com/davidmarble/virtualenvwrapper-win

Setup PostgreSQL database

Using pgAdmin III

  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.

Using pgAdmin 4

  1. Install the latest version of PostgreSQL for windows
  2. Run pgAdmin 4 (Start > Programs > PostgreSQL 9.6 > pgAdmin 4)
  3. Open the database on the sidebar on PostgreSQL 9.6 and enter password set during setup.
  4. Open the Logins/Roles tree, right click on it and select create
  5. Role name is "ckan_default", set a password on the second tab. On the privileges tab allow for table creation. Click Ok.
  6. Open the Databases tree, right click and select create.
  7. Name is "ckan_default" and Owner is "ckan_default". Encoding should be UTF8. Click Ok.

Setup SOLR

Using solr 4.9

  1. Download the latest version of solr
  2. Copy schema.xml from C:\src\ckan\config\solr to C:\solr-4.9.1\example\solr\collection1\conf
  3. Open a new DOS prompt in C:\solr-4.9.1\example
  4. Run java -jar start.jar
  5. 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 ckan
  6. Activate your virtual environment

    • workon ckan
  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/

Install extensions and themes

Extensions such as datapusher and datastore need to be activated in development.ini. For datastore follow install instructions here: http://docs.ckan.org/en/latest/maintaining/datastore.html

Other extensions and themes need to be installed in the virtualenv. From the folder of the extension, and with the virtualenv activated, run C:\src\ckan\ckanext\ckanext-theme\> python setup.py install

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.