How to Install CKAN 1.6 on Windows XP Professional - ckan/ckan GitHub Wiki

This is an example of installing CKAN on Windows, as a guide for Window server installs. It uses CKAN 1.6 and a Windows XP Professional machine.

Contact: David Read on the ckan-dev mailing list

Python packages

Non-python packages

Main install

C:\> \python26\Scripts\easy_install.exe virtualenv
<code>Searching for virtualenv
Reading http://pypi.python.org/simple/virtualenv/
Reading http://www.virtualenv.org
Reading http://virtualenv.openplans.org
Best match: virtualenv 1.7
Downloading http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.tar.gz
Best match: virtualenv 1.7
Processing virtualenv-1.7-py2.6.egg
virtualenv 1.7 is already the active version in easy-install.pth
Installing virtualenv-script.py script to C:\python26\Scripts
Installing virtualenv.exe script to C:\python26\Scripts
Installing virtualenv.exe.manifest script to C:\python26\Scripts

Using c:\python26\lib\site-packages\virtualenv-1.7-py2.6.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv
C:\> \python26\Scripts\virtualenv.exe --system-site-packages \pyenv
Overwriting \pyenv\lib\site.py with new content
Overwriting \pyenv\lib\orig-prefix.txt with new content
New python executable in \pyenv\Scripts\python.exe
Installing setuptools.................done.
Installing pip....................done.
Overwriting \pyenv\Scripts\activate_this.py with new content
C:\> \pyenv\Scripts\activate.bat
(pyenv) C:\> pip install -e git+https://github.com/okfn/ckan.git#egg=ckan
Obtaining ckan from git+https://github.com/okfn/ckan.git#egg=ckan
  Updating c:\pyenv\src\ckan clone
  Running setup.py egg_info for package ckan
    WARNING: ckanext.stats is a namespace package, but its __init__.py does
    not declare_namespace(); setuptools 0.7 will REQUIRE this!
    (See the setuptools manual under "Namespace Packages" for details.)

    warning: no files found matching '*' under directory 'ckanext\**\i18n'
    no previously-included directories found matching '.git'
Installing collected packages: ckan
  Running setup.py develop for ckan
    WARNING: ckanext.stats is a namespace package, but its __init__.py does
    not declare_namespace(); setuptools 0.7 will REQUIRE this!
    (See the setuptools manual under "Namespace Packages" for details.)

    warning: no files found matching '*' under directory 'ckanext\**\i18n'
    no previously-included directories found matching '.git'
    Creating c:\pyenv\lib\site-packages\ckan.egg-link (link to .)
    ckan 1.6.1a is already the active version in easy-install.pth
    Installing ckan-admin-script.py script to C:\pyenv\Scripts
    Installing ckan-admin.exe script to C:\pyenv\Scripts
    Installing ckan-admin.exe.manifest script to C:\pyenv\Scripts

    Installed c:\pyenv\src\ckan
Successfully installed ckan
Cleaning up...
  • Install pyutilib manually:
(pyenv) C:\>pip install pyutilib.component.core==4.1
Downloading/unpacking pyutilib.component.core==4.1
  Downloading pyutilib.component.core-4.1.tar.gz
  Running setup.py egg_info for package pyutilib.component.core
Installing collected packages: pyutilib.component.core
  Running setup.py install for pyutilib.component.core
    Skipping installation of C:\pyenv\Lib\site-packages\pyutilib\__init__.py (na
mespace package)
    Skipping installation of C:\pyenv\Lib\site-packages\pyutilib\component\__ini
t__.py (namespace package)
    Installing C:\pyenv\Lib\site-packages\pyutilib.component.core-4.1-py2.6-nspk
g.pth
Successfully installed pyutilib.component.core
Cleaning up...
  • Install flup manually:
 (pyenv) C:\> pip install hg+http://hg.saddi.com/flup@301a58656bfb#egg=flup
  • Install lxml manually:
(pyenv) C:\> easy_install --allow-hosts=lxml.de,*.python.org lxml==2.2.4
Processing dependencies for lxml==2.2.4
Finished processing dependencies for lxml==2.2.4
  • Comment out the "pyutilib" and "flup" lines in c:\pyenv\src\ckan\requires\lucid_missing.txt. i.e.:
 #-e svn+https://software.sandia.gov/svn/public/pyutilib/pyutilib.component.core/trunk@1972#egg=pyutilib.component.core

...

 #-e hg+http://hg.saddi.com/flup@301a58656bfb#egg=flup
 (pyenv) C:\> pip install -r pyenv/src/ckan/requires/lucid_missing.txt -r pyenv/src/ckan/requires/lucid_conflict.txt
 (pyenv) C:\> pip install -r \pyenv\src\ckan\requires\lucid_present.txt
  • Run PGAdmin III (Start, Programs, Postgres 9.1, PGAdmin III)
    • click in "Object browser" on Postgres 9.1 and enter password previously set.
    • Right click on "Login roles" and select "New Login Role..."
    • Role name is "ckanuser", set a password, default privileges. Click Ok.
    • Right click on "Databases" and select "New Database..."
    • Name is "ckantest" and Owner is "ckanuser". Encoding should be UTF8. Click Ok.
  • Create the config file
 (pyenv) C:\>cd \pyenv\src\ckan
 (pyenv) C:\pyenv\src\ckan>paster make-config ckan development.ini
Now you should edit the config files
  development.ini
  • Edit \pyenv\src\ckan\development.ini for sqlalchemy.url & search options (I used simple_search)
  • Initialise database
(pyenv) C:\pyenv\src\ckan>paster db init
C:\pyenv\lib\site-packages\formalchemy\forms.py:49: SADeprecationWarning: compil
e_mappers() is renamed to configure_mappers()
  compile_mappers() # initializes InstrumentedAttributes
Initialising DB: SUCCESS
  • Create some test data (optional)
(pyenv) C:\pyenv\src\ckan>paster create-test-data
C:\pyenv\lib\site-packages\formalchemy\forms.py:49: SADeprecationWarning: compil
e_mappers() is renamed to configure_mappers()
  compile_mappers() # initializes InstrumentedAttributes
Running setup_config() from ckan.websetup
2012-02-21 11:19:41,398 INFO  [ckan.websetup] Creating tables: SUCCESS
Creating basic test data
  • symbolic link to who.ini will cause problems, so remove and simply copy who.ini:
(pyenv) C:\pyenv\src\ckan>del who.ini

(pyenv) C:\pyenv\src\ckan>copy ckan\config\who.ini .\
        1 file(s) copied.
  • Start CKAN using the basic paster server:
(pyenv) C:\pyenv\src\ckan>paster serve --reload development.ini
Starting subprocess with file monitor
2012-02-21 11:14:31,602 WARNI [vdm] Skipping adding property Package.package_tag
_all to revisioned object
2012-02-21 11:14:31,614 WARNI [vdm] Skipping adding property Package.all_revisio
ns_unordered to revisioned object
2012-02-21 11:14:31,684 WARNI [vdm] Skipping adding property PackageTag.all_revi
sions_unordered to revisioned object
2012-02-21 11:14:31,733 WARNI [vdm] Skipping adding property Group.all_revisions
_unordered to revisioned object
2012-02-21 11:14:31,743 WARNI [vdm] Skipping adding property Member.all_revision
s_unordered to revisioned object
2012-02-21 11:14:31,763 WARNI [vdm] Skipping adding property GroupExtra.all_revi
sions_unordered to revisioned object
2012-02-21 11:14:31,834 WARNI [vdm] Skipping adding property PackageExtra.all_re
visions_unordered to revisioned object
2012-02-21 11:14:31,884 WARNI [vdm] Skipping adding property Resource.all_revisi
ons_unordered to revisioned object
2012-02-21 11:14:31,894 WARNI [vdm] Skipping adding property ResourceGroup.resou
rces_all to revisioned object
2012-02-21 11:14:31,894 WARNI [vdm] Skipping adding property ResourceGroup.all_r
evisions_unordered to revisioned object
2012-02-21 11:14:31,924 WARNI [vdm] Skipping adding property PackageRelationship
.all_revisions_unordered to revisioned object
C:\pyenv\lib\site-packages\formalchemy\forms.py:49: SADeprecationWarning: compil
e_mappers() is renamed to configure_mappers()
  compile_mappers() # initializes InstrumentedAttributes
Starting server in PID 2300.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000
   127.0.0.1 test.com
 (pyenv) C:\pyenv\src\ckan>copy "C:\Documents and Settings\David Read\My Document

s\Downloads\mod_wsgi-win32-ap22py26-3.3.so" "C:\Program Files\Apache Software Fo undation\Apache2.2\modules\mod_wsgi.so"

    • Add this line to the C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf:
 LoadModule wsgi_module modules/mod_wsgi.so
  • Configure the Apache vhost
    • In the Apache config (C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf) add a reference to a CKAN vhost file:
   Include conf/extra/httpd-vhosts-ckan.conf
    • Now create this file C:\Program Files\Apache Software Foundation\Apache2.2\conf/extra/httpd-vhosts-ckan.conf with the following content:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.test.com
    ServerAlias test.com
    DocumentRoot "C:/pyenv"
    <Directory />
      AllowOverride None
      Order Deny,Allow
    </directory>
    WSGIScriptAlias / /pyenv/Scripts/test.com.py

    # pass authorization info on (needed for rest api)
    WSGIPassAuthorization On
    ErrorLog "logs/test.com-error.log"
    CustomLog "logs/test.com-access.log" common
</virtualhost>
  • Now create the WSGI script it refers to C:\pyenv\Scripts\test.com.py as follows:
import os
pyenv_dir = '\pyenv'
config_file = 'development.ini'
pyenv_bin_dir = os.path.join(pyenv_dir, 'Scripts')
activate_this = os.path.join(pyenv_bin_dir, 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
from paste.deploy import loadapp
config_filepath = os.path.join(pyenv_dir, 'src', 'ckan', config_file)
from paste.script.util.logging_config import fileConfig
fileConfig(config_filepath)
application = loadapp('config:%s' % config_filepath)
  • Use the Apache service icon in the task bar to restart Apache, browse to test.com and see CKAN running.
    • If there is a problem, check the logs in C:\Program Files\Apache Software Foundation\Apache2.2\logs\
⚠️ **GitHub.com Fallback** ⚠️